Skip to content

Feat/cloud flows - #432

Draft
tsvetelinpetrov wants to merge 21 commits into
feat/cloud-quickstart-integrationfrom
feat/cloud_flows
Draft

Feat/cloud flows#432
tsvetelinpetrov wants to merge 21 commits into
feat/cloud-quickstart-integrationfrom
feat/cloud_flows

Conversation

@tsvetelinpetrov

@tsvetelinpetrov tsvetelinpetrov commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Comment to be added.

Uses those PRs: nordicsemi/pc-nrfconnect-shared#1142, nordicsemi/pc-nrfconnect-launcher#1313

Notes:

  • FW to be updated with teh latest!!!!

@github-actions

This comment has been minimized.

@tsvetelinpetrov tsvetelinpetrov added doc not required All PRs either need "doc required" or "doc not required". ui not required All PRs either need "ui required" or "ui not required". labels Jul 30, 2026
Comment thread resources/Logomark.png

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logo looks too small for retina. Is it feasible to use svg or add @2x version? if not quick to do then just ignore

Comment on lines +62 to +63
const stripped = cleanShellOutput(response || '');
const [, match] = stripped.match(regex) ?? [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this safe for all other devices?

* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
*/

// TODO: Replace this with a library that can handle ANSI removal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we can skip adding new dependency, better not to add :) or this regex is not complete?

Comment on lines +9 to +16
// Real:
const API_BASE = 'https://api.memfault.com/api/v0';
const MYNORDIC_BASE = 'https://api.memfault.com/mynordic';
// Mock:
// const API_BASE = 'http://127.0.0.1:8000';
// const MYNORDIC_BASE = 'http://127.0.0.1:8000/mynordic';

const POLL_INTERVAL_MS = 5000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using .env file or urls.ts / config.ts in the root is preferable. Otherwise it is hard to find configs / urls and manage them later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'd move interfaces to the types.ts to improve future file readability & AI parsing
  2. Guess too late to rewrite, but why not using RTK Query? I believe it should be already installed. Simplifies REST API manipulation a lot.

const time = dateHeader ? Date.parse(dateHeader) : NaN;
if (Number.isNaN(time)) {
throw new Error(
'Missing/unreadable server Date header (CORS: exposed?)',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this error appear in log or on the UI too? If on the UI, we need to provide more info. Maybe for the log and future debug we should add raw time value anyway.

}
};

interface TokenResponse {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep interfaces together :)

projectSlug: string,
params: RegisterDeviceParams,
): Promise<void> => {
const body: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract type / interface

Comment on lines +33 to +39
if (
accessToken &&
accessTokenExpiresAt &&
Date.now() < accessTokenExpiresAt - TOKEN_EXPIRY_BUFFER_MS
) {
return accessToken;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is quite strange hack that is usually not needed. Easy to break by local device date change. Any chance we can remove this hack and manage tokens as usual?


const TOKEN_EXPIRY_BUFFER_MS = 60_000;

export const getValidAccessToken =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this function could be an API middleware..

dispatch(
setAccessToken({
accessToken: fresh,
expiresAt: Date.now() + expiresIn * 1000,

@SlavaNordic SlavaNordic Aug 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you never know. this isn't reliable. Cloud changes config and this will not work

Comment on lines +66 to +73
// 1. provisioning (/me) — precondition
await provisionMyNordicAccount(idTokenRes.data);

// 2. access token (/token)
const accessToken = await dispatch(getValidAccessToken());

// 3. orgs/projects from /api/v0
const organizations = await fetchOrganizations(accessToken);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 1. provisioning (/me) — precondition
await provisionMyNordicAccount(idTokenRes.data);
// 2. access token (/token)
const accessToken = await dispatch(getValidAccessToken());
// 3. orgs/projects from /api/v0
const organizations = await fetchOrganizations(accessToken);
await provisionMyNordicAccount(idTokenRes.data);
const accessToken = await dispatch(getValidAccessToken());
const organizations = await fetchOrganizations(accessToken);

Comment on lines +84 to +85
selectedOrgSlug: firstOrg.slug,
selectedProjectSlug: projects[0]?.slug,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this sets values for the dropdown.. I do not think this should be stored in redux store at all.. Dropdown can decide what is default value by itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc not required All PRs either need "doc required" or "doc not required". ui not required All PRs either need "ui required" or "ui not required".

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants