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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
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
5 changes: 5 additions & 0 deletions .changeset/true-bears-divide.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Improve JSDoc comments
30 changes: 30 additions & 0 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-params-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
Expand DownExpand Up@@ -46,10 +47,13 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/reverification-config.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/session-verification-level.mdx",
"types/session-verification-types.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
Expand DownExpand Up@@ -140,10 +144,36 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
"backend/allowlist-identifier.mdx",
"backend/auth-object.mdx",
"backend/authenticate-request-options.mdx",
"backend/client.mdx",
"backend/email-address.mdx",
"backend/external-account.mdx",
"backend/identification-link.mdx",
"backend/invitation-status.mdx",
"backend/invitation.mdx",
"backend/organization-invitation-status.mdx",
"backend/organization-invitation.mdx",
"backend/organization-membership-public-user-data.mdx",
"backend/organization-membership.mdx",
"backend/organization-sync-target.mdx",
"backend/organization.mdx",
"backend/paginated-resource-response.mdx",
"backend/phone-number.mdx",
"backend/public-organization-data-json.mdx",
"backend/redirect-url.mdx",
"backend/saml-account.mdx",
"backend/saml-connection.mdx",
"backend/session-activity.mdx",
"backend/session.mdx",
"backend/user.mdx",
"backend/verification.mdx",
"backend/verify-machine-auth-token.mdx",
"backend/verify-token-options.mdx",
"backend/verify-token.mdx",
"backend/verify-webhook-options.mdx",
"backend/verify-webhook.mdx",
"backend/web3-wallet.mdx",
]
`;
45 changes: 45 additions & 0 deletions .typedoc/custom-plugin.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
'create-organization-params.mdx',
'authenticate-request-options.mdx',
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
];

/**
Expand All@@ -36,6 +40,18 @@ const LINK_REPLACEMENTS = [
['organization-domain-resource', '/docs/references/javascript/types/organization-domain'],
['organization-invitation-resource', '/docs/references/javascript/types/organization-invitation'],
['organization-membership-request-resource', '/docs/references/javascript/types/organization-membership-request'],
['session', '/docs/references/backend/types/backend-session'],
['session-activity', '/docs/references/backend/types/backend-session-activity'],
['organization', '/docs/references/backend/types/backend-organization'],
['public-organization-data-json', '#public-organization-data-json'],
['organization-membership-public-user-data', '#organization-membership-public-user-data'],
['identification-link', '/docs/references/backend/types/backend-identification-link'],
['verification', '/docs/references/backend/types/backend-verification'],
['email-address', '/docs/references/backend/types/backend-email-address'],
['external-account', '/docs/references/backend/types/backend-external-account'],
['phone-number', '/docs/references/backend/types/backend-phone-number'],
['saml-account', '/docs/references/backend/types/backend-saml-account'],
['web3-wallet', '/docs/references/backend/types/backend-web3-wallet'],
];

/**
Expand DownExpand Up@@ -84,6 +100,25 @@ function getCatchAllReplacements() {
pattern: /\| `SignInResource` \|/,
replace: '| [SignInResource](/docs/references/javascript/sign-in) |',
},
{
pattern: /`OrganizationPrivateMetadata`/g,
replace:
'[`OrganizationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-private-metadata)',
},
{
pattern: /OrganizationPublicMetadata/g,
replace: '[OrganizationPublicMetadata](/docs/references/javascript/types/metadata#organization-public-metadata)',
},
{
pattern: /`OrganizationInvitationPrivateMetadata`/g,
replace:
'[`OrganizationInvitationPrivateMetadata`](/docs/references/javascript/types/metadata#organization-invitation-private-metadata)',
},
{
pattern: /`OrganizationInvitationPublicMetadata`/g,
replace:
'[`OrganizationInvitationPublicMetadata`](/docs/references/javascript/types/metadata#organization-invitation-public-metadata)',
},
{
/**
* By default, `@deprecated` is output with `**Deprecated**`. We want to add a full stop to it.
Expand All@@ -105,6 +140,15 @@ function getCatchAllReplacements() {
pattern: /\*\*Example\*\* `([^`]+)`/g,
replace: 'Example: `$1`.',
},
{
/**
* By default, multiple `@example` are output with "**Examples** `value1` `value2`". We want to capture the values and place them inside "Examples: `value1`, `value2`."
*/
pattern: /\*\*Examples\*\* ((?:`[^`]+`)(?: `[^`]+`)*)/g,
replace: (/** @type {string} */ _match, /** @type {string} */ capturedGroup) => {
return `Examples: ${capturedGroup.split(' ').join(', ')}.`;
},
},
];
}

Expand All@@ -126,6 +170,7 @@ export function load(app) {

for (const { pattern, replace } of catchAllReplacements) {
if (output.contents) {
// @ts-ignore - Mixture of string and function replacements
output.contents = output.contents.replace(pattern, replace);
}
}
Expand Down
4 changes: 4 additions & 0 deletions .typedoc/custom-theme.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,10 @@ ${tabs}

return `<code>${output}</code>`;
},
/**
* Hide "Extends" and "Extended by" sections
*/
hierarchy: () => '',
};
}
}
24 changes: 24 additions & 0 deletions packages/backend/src/api/resources/AllowlistIdentifier.ts
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
import type { AllowlistIdentifierType } from './Enums';
import type { AllowlistIdentifierJSON } from './JSON';

/**
* The Backend `AllowlistIdentifier` object represents an identifier that has been added to the allowlist of your application. The Backend `AllowlistIdentifier` object is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/ListAllowlistIdentifiers) and is not directly accessible from the Frontend API.
*/
export class AllowlistIdentifier {
constructor(
/**
* A unique ID for the allowlist identifier.
*/
readonly id: string,
/**
* The [identifier](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) that was added to the allowlist.
*/
readonly identifier: string,
/**
* The type of the allowlist identifier.
*/
readonly identifierType: AllowlistIdentifierType,
/**
* The date when the allowlist identifier was first created.
*/
readonly createdAt: number,
/**
* The date when the allowlist identifier was last updated.
*/
readonly updatedAt: number,
/**
* The ID of the instance that this allowlist identifier belongs to.
*/
readonly instanceId?: string,
/**
* The ID of the invitation sent to the identifier.
*/
readonly invitationId?: string,
) {}

Expand Down
27 changes: 27 additions & 0 deletions packages/backend/src/api/resources/Client.ts
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
import type { ClientJSON } from './JSON';
import { Session } from './Session';

/**
* The Backend `Client` object is similar to the [`Client`](https://clerk.com/docs/references/javascript/client) object as it holds information about the authenticated sessions in the current device. However, the Backend `Client` object is different from the `Client` object in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/Clients#operation/GetClient) and is not directly accessible from the Frontend API.
*/
export class Client {
constructor(
/**
* The unique identifier for the `Client`.
*/
readonly id: string,
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} IDs associated with the `Client`.
*/
readonly sessionIds: string[],
/**
* An array of [Session](https://clerk.com/docs/references/backend/types/backend-session){{ target: '_blank' }} objects associated with the `Client`.
*/
readonly sessions: Session[],
/**
* The ID of the [`SignIn`](https://clerk.com/docs/references/javascript/sign-in){{ target: '_blank' }}.
*/
readonly signInId: string | null,
/**
* The ID of the [`SignUp`](https://clerk.com/docs/references/javascript/sign-up){{ target: '_blank' }}.
*/
readonly signUpId: string | null,
/**
* The ID of the last active [Session](https://clerk.com/docs/references/backend/types/backend-session).
*/
readonly lastActiveSessionId: string | null,
/**
* The date when the `Client` was first created.
*/
readonly createdAt: number,
/**
* The date when the `Client` was last updated.
*/
readonly updatedAt: number,
) {}

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,27 @@ import { ObjectType } from './JSON';
import { WaitlistEntry } from './WaitlistEntry';

type ResourceResponse<T> = {
/**
* An array that contains the fetched data.
*/
data: T;
};

/**
* An interface that describes the response of a method that returns a paginated list of resources.
*
* If the promise resolves, you will get back the [properties](#properties) listed below. `data` will be an array of the resource type you requested. You can use the `totalCount` property to determine how many total items exist remotely.
*
* Some methods that return this type allow pagination with the `limit` and `offset` parameters, in which case the first 10 items will be returned by default. For methods such as [`getAllowlistIdentifierList()`](https://clerk.com/docs/references/backend/allowlist/get-allowlist-identifier-list), which do not take a `limit` or `offset`, all items will be returned.
*
* If the promise is rejected, you will receive a `ClerkAPIResponseError` or network error.
*
* @interface
*/
export type PaginatedResourceResponse<T> = ResourceResponse<T> & {
/**
* The total count of data that exist remotely.
*/
totalCount: number;
};

Expand Down
19 changes: 19 additions & 0 deletions packages/backend/src/api/resources/EmailAddress.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,30 @@ import { IdentificationLink } from './IdentificationLink';
import type { EmailAddressJSON } from './JSON';
import { Verification } from './Verification';

/**
* The Backend `EmailAddress` object is a model around an email address. Email addresses are one of the [identifiers](https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#identifiers) used to provide identification for users.
*
* Email addresses must be **verified** to ensure that they are assigned to their rightful owners. The `EmailAddress` object holds all necessary state around the verification process.
*
* For implementation examples for adding and verifying email addresses, see the [email link custom flow](https://clerk.com/docs/custom-flows/email-links) and [email code custom flow](https://clerk.com/docs/custom-flows/add-email) guides.
*/
export class EmailAddress {
constructor(
/**
* The unique identifier for the email address.
*/
readonly id: string,
/**
* The value of the email address.
*/
readonly emailAddress: string,
/**
* An object holding information on the verification of the email address.
*/
readonly verification: Verification | null,
/**
* An array of objects containing information about any identifications that might be linked to the email address.
*/
readonly linkedTo: IdentificationLink[],
) {}

Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export type OAuthProvider =

export type OAuthStrategy = `oauth_${OAuthProvider}`;

/**
* @inline
*/
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
Expand All@@ -35,6 +38,9 @@ export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_fact

export type SignUpVerificationNextAction = 'needs_prepare' | 'needs_attempt' | '';

/**
* @inline
*/
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired';

export const DomainsEnrollmentModes = {
Expand All@@ -51,8 +57,17 @@ export const ActorTokenStatus = {
} as const;
export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorTokenStatus];

/**
* @inline
*/
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet';

/**
* @inline
*/
export type BlocklistIdentifierType = AllowlistIdentifierType;

/**
* @inline
*/
export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected';
Loading