hcloud-sdk 22.9.2 → 22.10.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 CHANGED
@@ -1,5 +1,11 @@
1
- ## [22.9.2](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/compare/v22.9.1...v22.9.2) (2026-07-30)
1
+ ## [22.10.0](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/compare/v22.9.3...v22.10.0) (2026-08-04)
2
+
3
+ ### Features
4
+
5
+ * add PASSKEY_NAME validation entity ([763896f](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/763896f99dd36dd2ad654d8acb1041411d09bb47))
6
+ * **idp:** add passkey login and registration support ([7c36e07](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/7c36e0734896e0631dbe580523e75ad8cc5c29cd))
2
7
 
3
8
  ### Bug Fixes
4
9
 
5
- * return pat token from agent creation from authorization header ([f1e31ea](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/f1e31eab0d53eb45e71c72aa7e88106d09319675))
10
+ * lint error ([721acec](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/721acecd56110e7a0ab434840cb2d0ff61e5016e))
11
+ * use storageId over storage in share items ([86a61da](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/86a61da52ce0ff896a8939c0aa42e771bd964187))
@@ -50,7 +50,8 @@ declare enum Entity {
50
50
  TAG_NAME = "TAG_NAME",
51
51
  TAG_COLOR = "TAG_COLOR",
52
52
  MODULE_NAME = "MODULE_NAME",
53
- LOG_COLLECTOR_NAME = "LOG_COLLECTOR_NAME"
53
+ LOG_COLLECTOR_NAME = "LOG_COLLECTOR_NAME",
54
+ PASSKEY_NAME = "PASSKEY_NAME"
54
55
  }
55
56
  declare class EntityDetails {
56
57
  private entity;
@@ -56,6 +56,7 @@ var Entity;
56
56
  Entity["TAG_COLOR"] = "TAG_COLOR";
57
57
  Entity["MODULE_NAME"] = "MODULE_NAME";
58
58
  Entity["LOG_COLLECTOR_NAME"] = "LOG_COLLECTOR_NAME";
59
+ Entity["PASSKEY_NAME"] = "PASSKEY_NAME";
59
60
  })(Entity || (exports.Entity = Entity = {}));
60
61
  class EntityDetails {
61
62
  constructor(name) {
@@ -386,4 +387,9 @@ const entityCollection = {
386
387
  minLength: 1,
387
388
  maxLength: 64,
388
389
  },
390
+ [Entity.PASSKEY_NAME]: {
391
+ pattern: /^[\w-. ]{3,128}$/i,
392
+ minLength: 3,
393
+ maxLength: 128,
394
+ },
389
395
  };
@@ -1,4 +1,3 @@
1
- import { StorageConfiguration } from "../../global/Storage";
2
1
  import { ReducedUser, ShareReducedUnlinkedUser, User } from "../../idp";
3
2
  import { ItemType } from "../asset";
4
3
  /**
@@ -42,7 +41,13 @@ export interface Share {
42
41
  name: string;
43
42
  type: ItemType.MEDIA_ASSET;
44
43
  thumbnailUrl: string;
45
- storage: StorageConfiguration;
44
+ storageId: string;
45
+ } | {
46
+ _id: string;
47
+ name: string;
48
+ type: ItemType.STACK;
49
+ thumbnailUrl: string;
50
+ storageId: string;
46
51
  })[];
47
52
  permissions?: string[];
48
53
  permissionGroups?: ShareAssetPermissionGroup[];
@@ -9,6 +9,7 @@ export * from "./organization/settings/oauthApp";
9
9
  export * from "./organization/team";
10
10
  export * from "./user";
11
11
  export * from "./user/GeneralSettings";
12
+ export * from "./user/Passkey";
12
13
  export * from "./user/Pat";
13
14
  export * from "./user/Scopes";
14
15
  export * from "./user/SuccessfulAuth";
@@ -26,6 +26,7 @@ __exportStar(require("./organization/settings/oauthApp"), exports);
26
26
  __exportStar(require("./organization/team"), exports);
27
27
  __exportStar(require("./user"), exports);
28
28
  __exportStar(require("./user/GeneralSettings"), exports);
29
+ __exportStar(require("./user/Passkey"), exports);
29
30
  __exportStar(require("./user/Pat"), exports);
30
31
  __exportStar(require("./user/Scopes"), exports);
31
32
  __exportStar(require("./user/SuccessfulAuth"), exports);
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Whether a passkey credential can be backed up and synced across multiple devices (e.g. via iCloud Keychain or
3
+ * Google Password Manager), or is bound to a single physical authenticator and cannot be synced
4
+ */
5
+ export declare enum DeviceType {
6
+ SINGLE_DEVICE = "SINGLE_DEVICE",
7
+ MULTI_DEVICE = "MULTI_DEVICE"
8
+ }
9
+ /**
10
+ * How an authenticator is connected to the client device during a WebAuthn ceremony
11
+ */
12
+ export declare enum AuthenticatorAttachment {
13
+ PLATFORM = "platform",// The authenticator is built into the client device (e.g. Touch ID, Windows Hello)
14
+ CROSS_PLATFORM = "cross-platform"
15
+ }
16
+ /**
17
+ * A transport an authenticator supports for communicating with the client device
18
+ */
19
+ export declare enum AuthenticatorTransport {
20
+ BLE = "ble",// Bluetooth Low Energy
21
+ CABLE = "cable",// Cloud-assisted Bluetooth Low Energy (caBLE)
22
+ HYBRID = "hybrid",// A client device (e.g. a phone) reachable via QR code and BLE pairing
23
+ INTERNAL = "internal",// The authenticator is part of the client device itself (platform authenticator)
24
+ NFC = "nfc",// Near Field Communication
25
+ SMART_CARD = "smart-card",// Smart Card
26
+ USB = "usb"
27
+ }
28
+ /**
29
+ * Public representation of a passkey registered by a user. Never includes the credential's public key or signature counter
30
+ */
31
+ export interface Passkey {
32
+ credentialId: string;
33
+ name: string;
34
+ deviceType?: DeviceType;
35
+ createDate: number;
36
+ lastUsedDate?: number;
37
+ }
38
+ /**
39
+ * The relying party a new passkey is being registered for
40
+ */
41
+ export interface PasskeyRelyingParty {
42
+ id: string;
43
+ name: string;
44
+ }
45
+ /**
46
+ * The user a new passkey is being registered for
47
+ */
48
+ export interface PasskeyUser {
49
+ id: string;
50
+ name: string;
51
+ displayName: string;
52
+ }
53
+ /**
54
+ * References an existing credential, used to either exclude it from a new registration or allow it for authentication
55
+ */
56
+ export interface PasskeyCredentialDescriptor {
57
+ id: string;
58
+ transports?: AuthenticatorTransport[];
59
+ }
60
+ /**
61
+ * A public key algorithm accepted for a new credential
62
+ */
63
+ export interface PasskeyPubKeyCredParam {
64
+ alg: number;
65
+ type: "public-key";
66
+ }
67
+ /**
68
+ * Constraints the relying party places on which authenticators may be used and how they must behave during registration
69
+ */
70
+ export interface PasskeyAuthenticatorSelection {
71
+ authenticatorAttachment?: AuthenticatorAttachment;
72
+ residentKey?: string;
73
+ requireResidentKey?: boolean;
74
+ userVerification?: string;
75
+ }
76
+ /**
77
+ * Options returned by the server to create a new passkey with an authenticator
78
+ */
79
+ export interface PasskeyRegistrationOptions {
80
+ rp: PasskeyRelyingParty;
81
+ user: PasskeyUser;
82
+ challenge: string;
83
+ pubKeyCredParams: PasskeyPubKeyCredParam[];
84
+ timeout?: number;
85
+ excludeCredentials?: PasskeyCredentialDescriptor[];
86
+ authenticatorSelection?: PasskeyAuthenticatorSelection;
87
+ attestation?: string;
88
+ extensions?: Record<string, unknown>;
89
+ }
90
+ /**
91
+ * Options returned by the server to authenticate with an existing passkey
92
+ */
93
+ export interface PasskeyAuthenticationOptions {
94
+ challenge: string;
95
+ timeout?: number;
96
+ rpId?: string;
97
+ allowCredentials?: PasskeyCredentialDescriptor[];
98
+ userVerification?: string;
99
+ extensions?: Record<string, unknown>;
100
+ }
101
+ /**
102
+ * The authenticator's response produced during passkey registration
103
+ */
104
+ export interface PasskeyAttestationResponse {
105
+ clientDataJSON: string;
106
+ attestationObject: string;
107
+ authenticatorData?: string;
108
+ transports?: AuthenticatorTransport[];
109
+ publicKeyAlgorithm?: number;
110
+ publicKey?: string;
111
+ }
112
+ /**
113
+ * The credential produced by the browser during passkey registration (the value returned by `navigator.credentials.create()`),
114
+ * together with a label for the new passkey.
115
+ */
116
+ export interface PasskeyRegistrationCredential {
117
+ id: string;
118
+ rawId: string;
119
+ response: PasskeyAttestationResponse;
120
+ authenticatorAttachment?: AuthenticatorAttachment;
121
+ clientExtensionResults: Record<string, unknown>;
122
+ type: "public-key";
123
+ name: string;
124
+ }
125
+ /**
126
+ * The authenticator's response produced during passkey authentication
127
+ * (part of the value returned by `navigator.credentials.get()`)
128
+ */
129
+ export interface PasskeyAssertionResponse {
130
+ clientDataJSON: string;
131
+ authenticatorData: string;
132
+ signature: string;
133
+ userHandle?: string;
134
+ }
135
+ /**
136
+ * The credential produced by the browser during passkey authentication (the value returned by `navigator.credentials.get()`)
137
+ */
138
+ export interface PasskeyAuthenticationCredential {
139
+ id: string;
140
+ rawId: string;
141
+ response: PasskeyAssertionResponse;
142
+ authenticatorAttachment?: AuthenticatorAttachment;
143
+ clientExtensionResults: Record<string, unknown>;
144
+ type: "public-key";
145
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthenticatorTransport = exports.AuthenticatorAttachment = exports.DeviceType = void 0;
4
+ /**
5
+ * Whether a passkey credential can be backed up and synced across multiple devices (e.g. via iCloud Keychain or
6
+ * Google Password Manager), or is bound to a single physical authenticator and cannot be synced
7
+ */
8
+ var DeviceType;
9
+ (function (DeviceType) {
10
+ DeviceType["SINGLE_DEVICE"] = "SINGLE_DEVICE";
11
+ DeviceType["MULTI_DEVICE"] = "MULTI_DEVICE";
12
+ })(DeviceType || (exports.DeviceType = DeviceType = {}));
13
+ /**
14
+ * How an authenticator is connected to the client device during a WebAuthn ceremony
15
+ */
16
+ var AuthenticatorAttachment;
17
+ (function (AuthenticatorAttachment) {
18
+ AuthenticatorAttachment["PLATFORM"] = "platform";
19
+ AuthenticatorAttachment["CROSS_PLATFORM"] = "cross-platform";
20
+ })(AuthenticatorAttachment || (exports.AuthenticatorAttachment = AuthenticatorAttachment = {}));
21
+ /**
22
+ * A transport an authenticator supports for communicating with the client device
23
+ */
24
+ var AuthenticatorTransport;
25
+ (function (AuthenticatorTransport) {
26
+ AuthenticatorTransport["BLE"] = "ble";
27
+ AuthenticatorTransport["CABLE"] = "cable";
28
+ AuthenticatorTransport["HYBRID"] = "hybrid";
29
+ AuthenticatorTransport["INTERNAL"] = "internal";
30
+ AuthenticatorTransport["NFC"] = "nfc";
31
+ AuthenticatorTransport["SMART_CARD"] = "smart-card";
32
+ AuthenticatorTransport["USB"] = "usb";
33
+ })(AuthenticatorTransport || (exports.AuthenticatorTransport = AuthenticatorTransport = {}));
@@ -6,6 +6,7 @@ import { IdpGuest } from "./guest";
6
6
  import { IdpInternal } from "./internal";
7
7
  import { IdpOAuth } from "./oauth";
8
8
  import { IdpOrganization } from "./organization";
9
+ import { IdpPasskey } from "./passkey";
9
10
  import { IdpRegistration } from "./registration";
10
11
  import { IdpUser } from "./user";
11
12
  export default class Idp extends Base {
@@ -19,6 +20,11 @@ export default class Idp extends Base {
19
20
  */
20
21
  get registration(): IdpRegistration;
21
22
  private _registration?;
23
+ /**
24
+ * Handles everything around passkey (WebAuthn) registration and login
25
+ */
26
+ get passkey(): IdpPasskey;
27
+ private _passkey?;
22
28
  /**
23
29
  * Handles everything around open authorization and openId requests
24
30
  */
@@ -17,6 +17,7 @@ const guest_1 = require("./guest");
17
17
  const internal_1 = require("./internal");
18
18
  const oauth_1 = require("./oauth");
19
19
  const organization_1 = require("./organization");
20
+ const passkey_1 = require("./passkey");
20
21
  const registration_1 = require("./registration");
21
22
  const user_1 = require("./user");
22
23
  class Idp extends Base_1.default {
@@ -38,6 +39,15 @@ class Idp extends Base_1.default {
38
39
  }
39
40
  return this._registration;
40
41
  }
42
+ /**
43
+ * Handles everything around passkey (WebAuthn) registration and login
44
+ */
45
+ get passkey() {
46
+ if (this._passkey === undefined) {
47
+ this._passkey = new passkey_1.IdpPasskey(this.options, this.axios);
48
+ }
49
+ return this._passkey;
50
+ }
41
51
  /**
42
52
  * Handles everything around open authorization and openId requests
43
53
  */
@@ -0,0 +1,56 @@
1
+ import Base, { MaybeRaw } from "../../Base";
2
+ import { Passkey, PasskeyAuthenticationCredential, PasskeyAuthenticationOptions, PasskeyRegistrationCredential, PasskeyRegistrationOptions } from "../../interfaces/idp/user/Passkey";
3
+ import { SuccessfulAuth } from "../../interfaces/idp/user/SuccessfulAuth";
4
+ export declare class IdpPasskey extends Base {
5
+ /**
6
+ * Requests options for registering a new passkey for the currently authenticated user. Pass the returned object
7
+ * into `navigator.credentials.create()` to have the browser/authenticator create a new credential, then submit
8
+ * the result to {@link verifyRegistration}.
9
+ * @returns PasskeyRegistrationOptions object to be passed into `navigator.credentials.create()`
10
+ */
11
+ createRegistrationOptions<R extends boolean = false>(raw?: {
12
+ raw: R;
13
+ }): Promise<MaybeRaw<R, PasskeyRegistrationOptions>>;
14
+ /**
15
+ * Verifies a newly created passkey credential and, if valid, stores it for the currently authenticated user.
16
+ * @param credential The credential returned by `navigator.credentials.create()`, together with a user-friendly name for the passkey
17
+ * @returns The newly stored Passkey
18
+ */
19
+ verifyRegistration<R extends boolean = false>(credential: PasskeyRegistrationCredential, raw?: {
20
+ raw: R;
21
+ }): Promise<MaybeRaw<R, Passkey>>;
22
+ /**
23
+ * Requests all passkeys registered for the currently authenticated user.
24
+ * @returns Array of Passkey objects
25
+ */
26
+ getPasskeys<R extends boolean = false>(raw?: {
27
+ raw: R;
28
+ }): Promise<MaybeRaw<R, Passkey[]>>;
29
+ /**
30
+ * Deletes a passkey registered for the currently authenticated user.
31
+ * @param credentialId Base64url-encoded credential ID of the passkey to delete
32
+ */
33
+ deletePasskey<R extends boolean = false>(credentialId: string, raw?: {
34
+ raw: R;
35
+ }): Promise<MaybeRaw<R, void>>;
36
+ /**
37
+ * Requests options for logging in with a passkey. This endpoint requires no authentication and does not identify
38
+ * the user upfront - any passkey registered for this relying party may be used. Pass the returned object into
39
+ * `navigator.credentials.get()` to have the browser/authenticator produce an assertion, then submit the result
40
+ * to {@link verifyAuthentication}.
41
+ * @returns PasskeyAuthenticationOptions object to be passed into `navigator.credentials.get()`
42
+ */
43
+ createAuthenticationOptions<R extends boolean = false>(raw?: {
44
+ raw: R;
45
+ }): Promise<MaybeRaw<R, PasskeyAuthenticationOptions>>;
46
+ /**
47
+ * Verifies a passkey authentication assertion. This endpoint requires no authentication. On success, the user is
48
+ * logged in and the response carries the Authorization header and auth_token cookie of the new session.
49
+ * @param credential The credential returned by `navigator.credentials.get()`
50
+ * @returns SuccessfulAuth object holding the token and the authenticated user
51
+ */
52
+ verifyAuthentication<R extends boolean = false>(credential: PasskeyAuthenticationCredential, raw?: {
53
+ raw: R;
54
+ }): Promise<MaybeRaw<R, SuccessfulAuth>>;
55
+ protected getEndpoint(endpoint: string): string;
56
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.IdpPasskey = void 0;
16
+ const Base_1 = __importDefault(require("../../Base"));
17
+ class IdpPasskey extends Base_1.default {
18
+ /**
19
+ * Requests options for registering a new passkey for the currently authenticated user. Pass the returned object
20
+ * into `navigator.credentials.create()` to have the browser/authenticator create a new credential, then submit
21
+ * the result to {@link verifyRegistration}.
22
+ * @returns PasskeyRegistrationOptions object to be passed into `navigator.credentials.create()`
23
+ */
24
+ createRegistrationOptions(raw) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const resp = yield this.axios.post(this.getEndpoint("/v1/user/passkey/options"));
27
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
28
+ });
29
+ }
30
+ /**
31
+ * Verifies a newly created passkey credential and, if valid, stores it for the currently authenticated user.
32
+ * @param credential The credential returned by `navigator.credentials.create()`, together with a user-friendly name for the passkey
33
+ * @returns The newly stored Passkey
34
+ */
35
+ verifyRegistration(credential, raw) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const resp = yield this.axios.post(this.getEndpoint("/v1/user/passkey/verify"), credential);
38
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
39
+ });
40
+ }
41
+ /**
42
+ * Requests all passkeys registered for the currently authenticated user.
43
+ * @returns Array of Passkey objects
44
+ */
45
+ getPasskeys(raw) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const resp = yield this.axios.get(this.getEndpoint("/v1/user/passkey"));
48
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
49
+ });
50
+ }
51
+ /**
52
+ * Deletes a passkey registered for the currently authenticated user.
53
+ * @param credentialId Base64url-encoded credential ID of the passkey to delete
54
+ */
55
+ deletePasskey(credentialId, raw) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const resp = yield this.axios.delete(this.getEndpoint(`/v1/user/passkey/${encodeURIComponent(credentialId)}`));
58
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : undefined);
59
+ });
60
+ }
61
+ /**
62
+ * Requests options for logging in with a passkey. This endpoint requires no authentication and does not identify
63
+ * the user upfront - any passkey registered for this relying party may be used. Pass the returned object into
64
+ * `navigator.credentials.get()` to have the browser/authenticator produce an assertion, then submit the result
65
+ * to {@link verifyAuthentication}.
66
+ * @returns PasskeyAuthenticationOptions object to be passed into `navigator.credentials.get()`
67
+ */
68
+ createAuthenticationOptions(raw) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const resp = yield this.axios.post(this.getEndpoint("/v1/auth/passkey/options"));
71
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
72
+ });
73
+ }
74
+ /**
75
+ * Verifies a passkey authentication assertion. This endpoint requires no authentication. On success, the user is
76
+ * logged in and the response carries the Authorization header and auth_token cookie of the new session.
77
+ * @param credential The credential returned by `navigator.credentials.get()`
78
+ * @returns SuccessfulAuth object holding the token and the authenticated user
79
+ */
80
+ verifyAuthentication(credential, raw) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ var _a;
83
+ const resp = yield this.axios.post(this.getEndpoint("/v1/auth/passkey/verify"), credential);
84
+ const authed = {
85
+ token: ((_a = resp.headers["authorization"]) === null || _a === void 0 ? void 0 : _a.toString()) || "",
86
+ user: resp.data,
87
+ };
88
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? Object.assign(Object.assign({}, resp), { data: authed }) : authed);
89
+ });
90
+ }
91
+ getEndpoint(endpoint) {
92
+ return `${this.options.server}/api/account${endpoint}`;
93
+ }
94
+ }
95
+ exports.IdpPasskey = IdpPasskey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hcloud-sdk",
3
- "version": "22.9.2",
3
+ "version": "22.10.0",
4
4
  "description": "hcloud platform sdk",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",