cloudcruise 0.0.6 → 1.0.1

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.
@@ -1,4 +1,4 @@
1
- import type { GetVaultEntriesFilters, VaultEntry } from './types.js';
1
+ import type { GetVaultEntriesFilters, VaultEntry, VaultTfaCode } from './types.js';
2
2
  export declare class VaultClient {
3
3
  private readonly makeRequest;
4
4
  private readonly encryptionKey;
@@ -15,6 +15,19 @@ export declare class VaultClient {
15
15
  * @param filters.decryptCredentials - Whether to decrypt sensitive fields (default: true)
16
16
  */
17
17
  get(filters?: GetVaultEntriesFilters): Promise<VaultEntry[]>;
18
+ /**
19
+ * Gets the current 2FA code for a single vault entry.
20
+ *
21
+ * The code returned depends on the credential's 2FA method:
22
+ * - Authenticator (TOTP): a freshly generated code, with `expires_in_seconds`.
23
+ * - Email: the most recently received code (within the freshness window), with `received_at`.
24
+ *
25
+ * SMS and magic-link credentials are not supported (the endpoint returns 409).
26
+ *
27
+ * @param permissioned_user_id - User identifier for the vault entry
28
+ * @param domain - Target domain of the vault entry
29
+ */
30
+ getTfaCode(permissioned_user_id: string, domain: string): Promise<VaultTfaCode>;
18
31
  /**
19
32
  * Updates an existing vault entry
20
33
  * @param updates - Vault entry updates including required fields
@@ -50,6 +50,30 @@ export class VaultClient {
50
50
  }
51
51
  return entries;
52
52
  }
53
+ /**
54
+ * Gets the current 2FA code for a single vault entry.
55
+ *
56
+ * The code returned depends on the credential's 2FA method:
57
+ * - Authenticator (TOTP): a freshly generated code, with `expires_in_seconds`.
58
+ * - Email: the most recently received code (within the freshness window), with `received_at`.
59
+ *
60
+ * SMS and magic-link credentials are not supported (the endpoint returns 409).
61
+ *
62
+ * @param permissioned_user_id - User identifier for the vault entry
63
+ * @param domain - Target domain of the vault entry
64
+ */
65
+ async getTfaCode(permissioned_user_id, domain) {
66
+ if (!permissioned_user_id) {
67
+ throw new Error('permissioned_user_id is required to get a TFA code');
68
+ }
69
+ if (!domain) {
70
+ throw new Error('domain is required to get a TFA code');
71
+ }
72
+ const params = new URLSearchParams();
73
+ params.append('permissioned_user_id', permissioned_user_id);
74
+ params.append('domain', domain);
75
+ return await this.makeRequest('GET', `/vault/tfa-code?${params.toString()}`);
76
+ }
53
77
  /**
54
78
  * Updates an existing vault entry
55
79
  * @param updates - Vault entry updates including required fields
@@ -48,3 +48,13 @@ export interface GetVaultEntriesFilters {
48
48
  domain?: string;
49
49
  decryptCredentials?: boolean;
50
50
  }
51
+ /**
52
+ * The current 2FA code for a vault entry. `expires_in_seconds` is present for
53
+ * authenticator (TOTP) codes; `received_at` is present for email codes.
54
+ */
55
+ export interface VaultTfaCode {
56
+ type: 'authenticator' | 'email';
57
+ code: string;
58
+ expires_in_seconds?: number;
59
+ received_at?: string;
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcruise",
3
- "version": "0.0.6",
3
+ "version": "1.0.1",
4
4
  "description": "The official CloudCruise JS/TS client.",
5
5
  "homepage": "https://github.com/CloudCruise/cloudcruise-js#readme",
6
6
  "bugs": {
@@ -18,16 +18,17 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "dev": "tsc --watch",
24
+ "prepublishOnly": "npm run build",
25
+ "test": "pnpm build && node --test test/*.test.js"
26
+ },
21
27
  "devDependencies": {
22
28
  "@types/node": "^20.0.0",
23
29
  "typescript": "^5.0.0"
24
30
  },
25
31
  "engines": {
26
32
  "node": ">=18.0.0"
27
- },
28
- "scripts": {
29
- "build": "tsc",
30
- "dev": "tsc --watch",
31
- "test": "pnpm build && node --test test/*.test.js"
32
33
  }
33
- }
34
+ }