@nordicsemiconductor/pc-nrfconnect-shared 256.0.0 → 257.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +8 -0
- package/dist/typings/ipc/auth.d.ts +48 -0
- package/dist/typings/ipc/auth.d.ts.map +1 -0
- package/ipc/auth.ts +115 -0
- package/package.json +1 -1
- package/release_notes.md +3 -1
- package/tsconfig.json +2 -1
package/Changelog.md
CHANGED
|
@@ -7,6 +7,14 @@ This project does _not_ adhere to
|
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
|
|
8
8
|
every new version is a new major version.
|
|
9
9
|
|
|
10
|
+
## 257.0.0 - 2026-08-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- IPC for myNordic authentication: sign-in, sign-in cancellation, single
|
|
15
|
+
sign-out, getting tokens and profile info, querying and subscribing to the
|
|
16
|
+
auth state.
|
|
17
|
+
|
|
10
18
|
## 256.0.0 - 2026-08-13
|
|
11
19
|
|
|
12
20
|
### Added
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type WebContents } from 'electron';
|
|
2
|
+
export type AuthStatus = 'signedIn' | 'signedOut' | 'signingIn' | 'signingOut' | 'interactionRequired';
|
|
3
|
+
export interface AuthState {
|
|
4
|
+
status: AuthStatus;
|
|
5
|
+
message?: string;
|
|
6
|
+
account?: AccountInfo;
|
|
7
|
+
}
|
|
8
|
+
export interface AccountInfo {
|
|
9
|
+
username: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ProfileInfo {
|
|
13
|
+
displayName?: string;
|
|
14
|
+
givenName?: string;
|
|
15
|
+
surname?: string;
|
|
16
|
+
mail?: string;
|
|
17
|
+
}
|
|
18
|
+
export type GenericAuthResult<T> = {
|
|
19
|
+
status: true;
|
|
20
|
+
data: T;
|
|
21
|
+
} | {
|
|
22
|
+
status: false;
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
type OnStateChanged = (state: AuthState) => void;
|
|
26
|
+
export declare const forRenderer: {
|
|
27
|
+
registerStartSignIn: (handler: (() => GenericAuthResult<null>) | (() => Promise<GenericAuthResult<null>>)) => void;
|
|
28
|
+
registerCancelSignIn: (handler: (() => GenericAuthResult<null>) | (() => Promise<GenericAuthResult<null>>)) => void;
|
|
29
|
+
registerSingleSignOut: (handler: (() => GenericAuthResult<null>) | (() => Promise<GenericAuthResult<null>>)) => void;
|
|
30
|
+
registerGetIdToken: (handler: ((scopes?: string[] | undefined) => GenericAuthResult<string>) | ((scopes?: string[] | undefined) => Promise<GenericAuthResult<string>>)) => void;
|
|
31
|
+
registerGetAccessToken: (handler: ((scopes?: string[] | undefined) => GenericAuthResult<string>) | ((scopes?: string[] | undefined) => Promise<GenericAuthResult<string>>)) => void;
|
|
32
|
+
registerGetProfileInfo: (handler: (() => GenericAuthResult<ProfileInfo>) | (() => Promise<GenericAuthResult<ProfileInfo>>)) => void;
|
|
33
|
+
registerGetAuthStatus: (handler: (() => AuthState) | (() => Promise<AuthState>)) => void;
|
|
34
|
+
registerOnStateChanged: (handler: OnStateChanged) => Electron.IpcRenderer;
|
|
35
|
+
broadcastStateChanged: (targets: Pick<WebContents, "send">[], state: AuthState) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const inMain: {
|
|
38
|
+
startSignIn: () => Promise<GenericAuthResult<null>>;
|
|
39
|
+
cancelSignIn: () => Promise<GenericAuthResult<null>>;
|
|
40
|
+
singleSignOut: () => Promise<GenericAuthResult<null>>;
|
|
41
|
+
getAccessToken: (scopes?: string[] | undefined) => Promise<GenericAuthResult<string>>;
|
|
42
|
+
getIdToken: (scopes?: string[] | undefined) => Promise<GenericAuthResult<string>>;
|
|
43
|
+
getProfileInfo: () => Promise<GenericAuthResult<ProfileInfo>>;
|
|
44
|
+
registerOnStateChanged: (handler: OnStateChanged) => Electron.IpcRenderer;
|
|
45
|
+
getAuthStatus: () => Promise<AuthState>;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../ipc/auth.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAkB5C,MAAM,MAAM,UAAU,GAChB,UAAU,GACV,WAAW,GACX,WAAW,GACX,YAAY,GACZ,qBAAqB,CAAC;AAE5B,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,IACzB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACzB;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAGvC,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AAwCjD,eAAO,MAAM,WAAW;;;;;;;;;qCA5BX,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,SAC7B,SAAS;CAqCnB,CAAC;AACF,eAAO,MAAM,MAAM;;;;;;;;;CASlB,CAAC"}
|
package/ipc/auth.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { type WebContents } from 'electron';
|
|
8
|
+
|
|
9
|
+
import { broadcast, onBroadcasted } from './infrastructure/mainToRenderer';
|
|
10
|
+
import { handle, invoke } from './infrastructure/rendererToMain';
|
|
11
|
+
|
|
12
|
+
const channel = {
|
|
13
|
+
startSignIn: 'auth:start',
|
|
14
|
+
cancelSignIn: 'auth:cancel-sign-in',
|
|
15
|
+
singleSignOut: 'auth:single-sign-out',
|
|
16
|
+
getIdToken: 'auth:get-id-token',
|
|
17
|
+
getAccessToken: 'auth:get-access-token',
|
|
18
|
+
getProfileInfo: 'auth:get-profile-info',
|
|
19
|
+
getStatus: 'auth:get-status',
|
|
20
|
+
onStateChanged: 'auth:on-state-changed',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const AUTH_STATE_SUBCHANNEL = 'auth-state';
|
|
24
|
+
|
|
25
|
+
export type AuthStatus =
|
|
26
|
+
| 'signedIn'
|
|
27
|
+
| 'signedOut'
|
|
28
|
+
| 'signingIn'
|
|
29
|
+
| 'signingOut'
|
|
30
|
+
| 'interactionRequired';
|
|
31
|
+
|
|
32
|
+
export interface AuthState {
|
|
33
|
+
status: AuthStatus;
|
|
34
|
+
message?: string;
|
|
35
|
+
account?: AccountInfo;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface AccountInfo {
|
|
39
|
+
username: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ProfileInfo {
|
|
44
|
+
displayName?: string;
|
|
45
|
+
givenName?: string;
|
|
46
|
+
surname?: string;
|
|
47
|
+
mail?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type GenericAuthResult<T> =
|
|
51
|
+
| { status: true; data: T }
|
|
52
|
+
| { status: false; error: string };
|
|
53
|
+
|
|
54
|
+
type GetAuthStatus = () => AuthState;
|
|
55
|
+
type OnStateChanged = (state: AuthState) => void;
|
|
56
|
+
type StartSignIn = () => GenericAuthResult<null>;
|
|
57
|
+
type CancelSignIn = () => GenericAuthResult<null>;
|
|
58
|
+
type SingleSignOut = () => GenericAuthResult<null>;
|
|
59
|
+
type GetAccessToken = (scopes?: string[]) => GenericAuthResult<string>;
|
|
60
|
+
type GetIdToken = (scopes?: string[]) => GenericAuthResult<string>;
|
|
61
|
+
type GetProfileInfo = () => GenericAuthResult<ProfileInfo>;
|
|
62
|
+
|
|
63
|
+
const broadcastStateChangedRaw = broadcast<OnStateChanged>(
|
|
64
|
+
channel.onStateChanged,
|
|
65
|
+
);
|
|
66
|
+
const broadcastStateChanged = (
|
|
67
|
+
targets: Pick<WebContents, 'send'>[],
|
|
68
|
+
state: AuthState,
|
|
69
|
+
) => broadcastStateChangedRaw(AUTH_STATE_SUBCHANNEL, targets, state);
|
|
70
|
+
|
|
71
|
+
const registerOnStateChanged = onBroadcasted<OnStateChanged>(
|
|
72
|
+
channel.onStateChanged,
|
|
73
|
+
AUTH_STATE_SUBCHANNEL,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const getAuthStatus = invoke<GetAuthStatus>(channel.getStatus);
|
|
77
|
+
const registerGetAuthStatus = handle<GetAuthStatus>(channel.getStatus);
|
|
78
|
+
|
|
79
|
+
const startSignIn = invoke<StartSignIn>(channel.startSignIn);
|
|
80
|
+
const registerStartSignIn = handle<StartSignIn>(channel.startSignIn);
|
|
81
|
+
const cancelSignIn = invoke<CancelSignIn>(channel.cancelSignIn);
|
|
82
|
+
const registerCancelSignIn = handle<CancelSignIn>(channel.cancelSignIn);
|
|
83
|
+
|
|
84
|
+
const singleSignOut = invoke<SingleSignOut>(channel.singleSignOut);
|
|
85
|
+
const registerSingleSignOut = handle<SingleSignOut>(channel.singleSignOut);
|
|
86
|
+
|
|
87
|
+
const getIdToken = invoke<GetIdToken>(channel.getIdToken);
|
|
88
|
+
const registerGetIdToken = handle<GetIdToken>(channel.getIdToken);
|
|
89
|
+
const getAccessToken = invoke<GetAccessToken>(channel.getAccessToken);
|
|
90
|
+
const registerGetAccessToken = handle<GetAccessToken>(channel.getAccessToken);
|
|
91
|
+
|
|
92
|
+
const getProfileInfo = invoke<GetProfileInfo>(channel.getProfileInfo);
|
|
93
|
+
const registerGetProfileInfo = handle<GetProfileInfo>(channel.getProfileInfo);
|
|
94
|
+
|
|
95
|
+
export const forRenderer = {
|
|
96
|
+
registerStartSignIn,
|
|
97
|
+
registerCancelSignIn,
|
|
98
|
+
registerSingleSignOut,
|
|
99
|
+
registerGetIdToken,
|
|
100
|
+
registerGetAccessToken,
|
|
101
|
+
registerGetProfileInfo,
|
|
102
|
+
registerGetAuthStatus,
|
|
103
|
+
registerOnStateChanged,
|
|
104
|
+
broadcastStateChanged,
|
|
105
|
+
};
|
|
106
|
+
export const inMain = {
|
|
107
|
+
startSignIn,
|
|
108
|
+
cancelSignIn,
|
|
109
|
+
singleSignOut,
|
|
110
|
+
getAccessToken,
|
|
111
|
+
getIdToken,
|
|
112
|
+
getProfileInfo,
|
|
113
|
+
registerOnStateChanged,
|
|
114
|
+
getAuthStatus,
|
|
115
|
+
};
|
package/package.json
CHANGED
package/release_notes.md
CHANGED