Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The js-controller repository is a monorepo which is managed via `lerna`. Every f
To install the dependencies, execute

```bash
npm i --ignore-scripts
npm ci --ignore-scripts
```

in the root folder of the project.
Expand Down
2 changes: 2 additions & 0 deletions packages/types-dev/objects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ declare global {
password: string;
/** Whether this user is enabled */
enabled: boolean;
/** External authentications besides password, e.g. OIDC */
externalAuthentication?: Record<string, unknown>;

// Make it possible to narrow the object type using the custom property
custom?: undefined;
Expand Down
18 changes: 16 additions & 2 deletions packages/types-public/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ function objectChangeHandler(id: string, object: ioBroker.Object | null | undefi
case 'instance':
case 'meta':
case 'script':
case 'user':
// nothing special here, update these tests when we have specialized definitions
break;

case 'user': {
if (object.common.externalAuthentication?.oidc) {
/** It is up to the dev how this looks like hence, oidc is of type unknown */
const oidc = object.common.externalAuthentication.oidc as { sub: string };
oidc.sub === 'foo';
}
break;
}
case 'state':
if (object.acl) {
object.acl.state.toFixed();
Expand Down Expand Up @@ -891,6 +897,14 @@ const _userObject: ioBroker.UserObject = {
native: {},
};

/** With external auth */
const _userObjectExt: ioBroker.UserObject = {
_id: 'system.user.me',
type: 'user',
common: { name: 'me', password: '*****', enabled: true, externalAuthentication: { oidc: { sub: 'bar' } } },
native: {},
};

// Ensure that getForeignObject tries to resolve a specific object type
async () => {
const inst: ioBroker.InstanceObject | null | undefined =
Expand Down
Loading