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
3 changes: 0 additions & 3 deletions .github/actions/npm-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Publish release to npm
inputs:
node-version:
required: true
npm-token:
required: true
version:
required: true
require-build:
Expand Down Expand Up @@ -48,5 +46,4 @@ runs:
fi
npm publish --provenance --tag $TAG
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
VERSION: ${{ inputs.version }}
3 changes: 2 additions & 1 deletion .github/actions/release-create/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ runs:
using: composite

steps:
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
- uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # [email protected]
with:
body: ${{ inputs.body }}
name: ${{ inputs.name }}
tag_name: ${{ inputs.tag }}
target_commitish: ${{ inputs.commit }}
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
make_latest: false
fail_on_unmatched_files: ${{ inputs.fail_on_unmatched_files }}
files: ${{ inputs.files }}
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ on:
secrets:
github-token:
required: true
npm-token:
required: true

### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions/` and append `@latest` after the common `dx-sdk-actions` repo is made public.
### TODO: Also remove `get-prerelease`, `get-version`, `release-create`, `tag-create` and `tag-exists` actions from this repo's .github/actions folder once the repo is public.
Expand All @@ -26,6 +24,9 @@ jobs:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write

steps:
# Checkout the code
Expand Down Expand Up @@ -70,7 +71,6 @@ jobs:
require-build: ${{ inputs.require-build }}
release-directory: ${{ inputs.release-directory }}
version: ${{ steps.get_version.outputs.version }}
npm-token: ${{ secrets.npm-token }}

# Create a release for the tag
- uses: ./.github/actions/release-create
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ jobs:
node-version: 18
require-build: true
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ on:
pull_request:
branches:
- master
- v4
push:
branches:
- master
- v4

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
cancel-in-progress: ${{ !contains(fromJSON('["refs/heads/master", "refs/heads/v4"]'), github.ref) }}

jobs:
build:
Expand Down
18 changes: 9 additions & 9 deletions src/auth/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@ export class Database extends BaseAuthAPI {
);

// Transform the response to ensure id field is always available
const jsonResponse = await JSONApiResponse.fromResponse(response);
const jsonResponse = await JSONApiResponse.fromResponse(response);

if (jsonResponse.data) {
const data = jsonResponse.data as Record<string, unknown>;
// Map _id or user_id to id
if (!data.id && (data._id || data.user_id)) {
data.id = data._id || data.user_id;
}
}
if (jsonResponse.data) {
const data = jsonResponse.data as Record<string, unknown>;
// Map _id or user_id to id
if (!data.id && (data._id || data.user_id)) {
data.id = data._id || data.user_id;
}
}

return jsonResponse as JSONApiResponse<SignUpResponse>;
return jsonResponse as JSONApiResponse<SignUpResponse>;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/management/__generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
/**
* List of IP addresses or CIDR blocks to allowlist
*/
export interface BotDetectionAllowlist extends Array<BotDetectionIpAddressOrCidrBlock> {}
export type BotDetectionAllowlist = Array<BotDetectionIpAddressOrCidrBlock>;

/**
* The policy that defines how often to show CAPTCHA
Expand Down Expand Up @@ -6771,8 +6771,7 @@
/**
*
*/
export interface GetConnectionsKeysResponseContent
extends Array<GetConnectionsKeysResponseContentInner> {}
export type GetConnectionsKeysResponseContent = Array<GetConnectionsKeysResponseContentInner>;
/**
*
*/
Expand Down Expand Up @@ -14939,7 +14938,7 @@
/**
*
*/
export interface PostFormsRequestNodesInnerAnyOf2ConfigComponentsInnerAnyOf2AnyOf13Config {}

Check warning on line 14941 in src/management/__generated/models/index.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.17)

An empty interface is equivalent to `{}`

Check warning on line 14941 in src/management/__generated/models/index.ts

View workflow job for this annotation

GitHub Actions / Build and Test (20.3)

An empty interface is equivalent to `{}`
/**
*
*/
Expand Down Expand Up @@ -19972,7 +19971,7 @@
/**
* SAML mapping override for this strategy
*/
export interface UserAttributeProfileSamlMapping extends Array<string> {}
export type UserAttributeProfileSamlMapping = Array<string>;
/**
* Strategy-specific overrides for this attribute
*/
Expand Down Expand Up @@ -20186,7 +20185,7 @@
/**
* SAML mapping for user ID
*/
export interface UserAttributeProfileUserIdSamlMapping extends Array<string> {}
export type UserAttributeProfileUserIdSamlMapping = Array<string>;
/**
*
*/
Expand Down
56 changes: 28 additions & 28 deletions test/auth/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ describe('Database', () => {
});

it("should signup a user when response param for id is 'user_id'", async () => {
const database = new Database(opts);
const email = "[email protected]";
const { data } = await database.signUp({
email,
password: PASSWORD,
connection: "Username-Password-Authentication",
});
expect(data).toEqual({
user_id: "test-id",
id: "test-id",
email_verified: false,
email,
});
});
const database = new Database(opts);
const email = '[email protected]';
const { data } = await database.signUp({
email,
password: PASSWORD,
connection: 'Username-Password-Authentication',
});
expect(data).toEqual({
user_id: 'test-id',
id: 'test-id',
email_verified: false,
email,
});
});

it("should signup a user when response param for id is 'id'", async () => {
const database = new Database(opts);
const email = "[email protected]";
const { data } = await database.signUp({
email,
password: PASSWORD,
connection: "Username-Password-Authentication",
});
expect(data).toEqual({
id: "test-id",
email_verified: false,
email,
});
});
it("should signup a user when response param for id is 'id'", async () => {
const database = new Database(opts);
const email = '[email protected]';
const { data } = await database.signUp({
email,
password: PASSWORD,
connection: 'Username-Password-Authentication',
});
expect(data).toEqual({
id: 'test-id',
email_verified: false,
email,
});
});

it('should require connection', async () => {
const database = new Database(opts);
Expand Down
49 changes: 37 additions & 12 deletions test/management/organizations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ describe('OrganizationsManager', () => {
const operation = organizations.postOrganizationClientGrants(requestParameters, requestBody);
const expectedResponse: GetOrganizationClientGrants200ResponseOneOfInner = <
GetOrganizationClientGrants200ResponseOneOfInner
>{};
>{};
const uri = `/organizations/{id}/client-grants`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
Expand Down Expand Up @@ -1571,7 +1571,9 @@ describe('OrganizationsManager', () => {
};

beforeEach(() => {
request = nock(API_URL).get(`/organizations/${data.id}/discovery-domains`).reply(200, responseData);
request = nock(API_URL)
.get(`/organizations/${data.id}/discovery-domains`)
.reply(200, responseData);
});

it('should return a promise when no callback is given', (done) => {
Expand Down Expand Up @@ -1652,7 +1654,10 @@ describe('OrganizationsManager', () => {
});

it('should return a promise if no callback is given', (done) => {
organizations.getDiscoveryDomain(data).then(done.bind(null, null)).catch(done.bind(null, null));
organizations
.getDiscoveryDomain(data)
.then(done.bind(null, null))
.catch(done.bind(null, null));
});

it('should perform a GET request to /api/v2/organizations/:id/discovery-domains/:discovery_domain_id', (done) => {
Expand Down Expand Up @@ -1690,11 +1695,15 @@ describe('OrganizationsManager', () => {
});

it('should return error when id is not sent', async () => {
await expect(organizations.getDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)).rejects.toThrow(RequiredError);
await expect(
organizations.getDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)
).rejects.toThrow(RequiredError);
});

it('should return error when discovery_domain_id is not sent', async () => {
await expect(organizations.getDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(RequiredError);
await expect(organizations.getDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(
RequiredError
);
});
});

Expand Down Expand Up @@ -1724,7 +1733,10 @@ describe('OrganizationsManager', () => {
});

it('should return a promise if no callback is given', (done) => {
organizations.createDiscoveryDomain(data, body).then(done.bind(null, null)).catch(done.bind(null, null));
organizations
.createDiscoveryDomain(data, body)
.then(done.bind(null, null))
.catch(done.bind(null, null));
});

it('should pass any errors to the promise catch handler', (done) => {
Expand All @@ -1746,7 +1758,9 @@ describe('OrganizationsManager', () => {
});

it('should return error when id is not sent', async () => {
await expect(organizations.createDiscoveryDomain({} as any, body)).rejects.toThrow(RequiredError);
await expect(organizations.createDiscoveryDomain({} as any, body)).rejects.toThrow(
RequiredError
);
});

it('should pass the data in the body of the request', (done) => {
Expand Down Expand Up @@ -1800,7 +1814,10 @@ describe('OrganizationsManager', () => {
});

it('should return a promise if no callback is given', (done) => {
organizations.updateDiscoveryDomain(data, body).then(done.bind(null, null)).catch(done.bind(null, null));
organizations
.updateDiscoveryDomain(data, body)
.then(done.bind(null, null))
.catch(done.bind(null, null));
});

it('should pass any errors to the promise catch handler', (done) => {
Expand All @@ -1824,11 +1841,15 @@ describe('OrganizationsManager', () => {
});

it('should return error when id is not sent', async () => {
await expect(organizations.updateDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any, body)).rejects.toThrow(RequiredError);
await expect(
organizations.updateDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any, body)
).rejects.toThrow(RequiredError);
});

it('should return error when discovery_domain_id is not sent', async () => {
await expect(organizations.updateDiscoveryDomain({ id: 'org_123' } as any, body)).rejects.toThrow(RequiredError);
await expect(
organizations.updateDiscoveryDomain({ id: 'org_123' } as any, body)
).rejects.toThrow(RequiredError);
});

it('should pass the data in the body of the request', (done) => {
Expand Down Expand Up @@ -1872,7 +1893,9 @@ describe('OrganizationsManager', () => {
});

it('should validate empty id', async () => {
await expect(organizations.deleteDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)).rejects.toThrow(RequiredError);
await expect(
organizations.deleteDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)
).rejects.toThrow(RequiredError);
});

it('should return a promise if no callback is given', (done) => {
Expand Down Expand Up @@ -1900,7 +1923,9 @@ describe('OrganizationsManager', () => {
});

it('should return error when discovery_domain_id is not sent', async () => {
await expect(organizations.deleteDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(RequiredError);
await expect(organizations.deleteDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(
RequiredError
);
});

it('should include the token in the Authorization header', (done) => {
Expand Down
4 changes: 2 additions & 2 deletions test/management/user-attribute-profiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ describe('UserAttributeProfilesManager', () => {
auth0_mapping: 'testUser',
oidc_mapping: {
mapping: 'preferred_username',
display_name: 'Display Name'
}
display_name: 'Display Name',
},
},
},
};
Expand Down
8 changes: 6 additions & 2 deletions test/management/users.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1799,8 +1799,12 @@ describe('UsersManager', () => {
expect(connectedAccounts.data.connected_accounts).toBeInstanceOf(Array);
expect(connectedAccounts.data.connected_accounts.length).toBe(connectedAccountsData.length);
expect(connectedAccounts.data.connected_accounts[0].id).toBe(connectedAccountsData[0].id);
expect(connectedAccounts.data.connected_accounts[0].connection).toBe(connectedAccountsData[0].connection);
expect(connectedAccounts.data.connected_accounts[0].strategy).toBe(connectedAccountsData[0].strategy);
expect(connectedAccounts.data.connected_accounts[0].connection).toBe(
connectedAccountsData[0].connection
);
expect(connectedAccounts.data.connected_accounts[0].strategy).toBe(
connectedAccountsData[0].strategy
);
});

it('should pass the parameters in the query-string', async () => {
Expand Down
Loading