-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Device Authentication flow support
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
- Loading branch information
1 parent
e6b0afa
commit ae3bdab
Showing
22 changed files
with
1,110 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2023 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
***********************************************************************/ | ||
|
||
/* eslint-disable header/header */ | ||
|
||
export function arrayEquals<T>(first: ReadonlyArray<T> | undefined, second: ReadonlyArray<T> | undefined, itemEquals: (a: T, b: T) => boolean = (a, b) => a === b): boolean { | ||
if (first === second) { | ||
return true; | ||
} | ||
if (!first || !second) { | ||
return false; | ||
} | ||
if (first.length !== second.length) { | ||
return false; | ||
} | ||
for (let i = 0, len = first.length; i < len; i++) { | ||
if (!itemEquals(first[i], second[i])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
export function base64Encode(toEncode: string): string { | ||
return Buffer.from(toEncode, 'binary').toString('base64'); | ||
} | ||
|
||
export function randomString(length: number): string { | ||
let result = ''; | ||
while (result.length < length) { | ||
result += 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'[ | ||
(Math.random() * 60) | 0 | ||
]; | ||
} | ||
return result; | ||
} | ||
|
||
export function createLabelsSelector(labels: { [key: string]: string; }): string { | ||
return Object.entries(labels) | ||
.map(([key, value]) => `${key}=${value}`) | ||
.join(','); | ||
} |
Oops, something went wrong.