@opengeni/contracts 3.1.2 → 3.2.2

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/src/vaults.ts CHANGED
@@ -16,7 +16,7 @@ export const VaultOwnerKind = /* @__PURE__ */ defineSchema(() =>
16
16
  );
17
17
  export type VaultOwnerKind = z.infer<typeof VaultOwnerKind>;
18
18
  export const VaultSource = /* @__PURE__ */ defineSchema(() =>
19
- z.enum(["opengeni", "onepassword", "host"]),
19
+ z.enum(["opengeni", "onepassword", "host", "external", "protonpass", "keeper", "bitwarden"]),
20
20
  );
21
21
  export type VaultSource = z.infer<typeof VaultSource>;
22
22
  export const VaultMode = /* @__PURE__ */ defineSchema(() => z.enum(["read_write", "read_only"]));
@@ -33,6 +33,44 @@ export const VaultFieldKind = /* @__PURE__ */ defineSchema(() =>
33
33
  z.enum(["text", "concealed", "totp", "file"]),
34
34
  );
35
35
  export type VaultFieldKind = z.infer<typeof VaultFieldKind>;
36
+
37
+ /** Effective operations, not a promise that upstream permissions cannot change. */
38
+ export const VaultProviderOperations = /* @__PURE__ */ defineSchema(() =>
39
+ z
40
+ .object({
41
+ createItemTypes: z.array(VaultItemType).max(5),
42
+ updateItem: z.boolean(),
43
+ removeField: z.boolean(),
44
+ archiveItem: z.boolean(),
45
+ archiveKind: z.enum(["archive", "trash", "none"]),
46
+ /** Permanent provider deletion is deliberately not exposed. */
47
+ deleteItem: z.literal(false),
48
+ restoreItem: z.boolean(),
49
+ readFiles: z.boolean(),
50
+ writeFiles: z.boolean(),
51
+ createTotp: z.boolean(),
52
+ updateTotp: z.boolean(),
53
+ createVault: z.boolean(),
54
+ restoreFieldHistory: z.boolean(),
55
+ })
56
+ .strict(),
57
+ );
58
+ export type VaultProviderOperations = z.infer<typeof VaultProviderOperations>;
59
+
60
+ /** A successful mirror check does not prove a customer's upstream cache is current. */
61
+ export const VaultProviderFreshness = /* @__PURE__ */ defineSchema(() =>
62
+ z
63
+ .object({
64
+ state: z.enum(["current", "stale", "refreshing", "unavailable"]),
65
+ lastCheckedAt: z.string().datetime().nullable(),
66
+ sourceSyncedAt: z.string().datetime().nullable(),
67
+ source: z.enum(["live", "cache", "unknown"]),
68
+ errorCode: z.string().max(100).nullable(),
69
+ retryAt: z.string().datetime().nullable(),
70
+ })
71
+ .strict(),
72
+ );
73
+ export type VaultProviderFreshness = z.infer<typeof VaultProviderFreshness>;
36
74
  /** Lookup order for references that name no vault; index = tier. */
37
75
  export const VAULT_LOOKUP_TIERS = ["task", "user", "workspace", "organization"] as const;
38
76
  export type VaultLookupTier = (typeof VAULT_LOOKUP_TIERS)[number];
@@ -170,6 +208,8 @@ export const VaultSummary = /* @__PURE__ */ defineSchema(() =>
170
208
  lastSyncedAt: z.string().nullable(),
171
209
  rateLimitedUntil: z.string().nullable(),
172
210
  providerConnectionId: z.string().uuid().nullable(),
211
+ providerOperations: VaultProviderOperations.optional(),
212
+ freshness: VaultProviderFreshness.optional(),
173
213
  /** Organization and Only-me vaults; null for workspace and task vaults. */
174
214
  availability: VaultAvailability.nullable(),
175
215
  isDefault: z.boolean(),
@@ -483,6 +523,9 @@ export const ProviderVaultMeta = /* @__PURE__ */ defineSchema(() =>
483
523
  name: z.string(),
484
524
  itemCount: z.number().int().nullable(),
485
525
  linkedVaultId: z.string().uuid().nullable(),
526
+ /** Unknown means the provider does not expose the grant; writes still check upstream. */
527
+ writeAccess: z.enum(["read_only", "read_write", "unknown"]).optional(),
528
+ operations: VaultProviderOperations.optional(),
486
529
  }),
487
530
  );
488
531
  export type ProviderVaultMeta = z.infer<typeof ProviderVaultMeta>;
@@ -542,11 +585,133 @@ export const DisconnectOnePasswordResponse = /* @__PURE__ */ defineSchema(() =>
542
585
  );
543
586
  export type DisconnectOnePasswordResponse = z.infer<typeof DisconnectOnePasswordResponse>;
544
587
 
588
+ /** Providers installed through the generic connection lifecycle. */
589
+ export const ExternalVaultProviderKind = /* @__PURE__ */ defineSchema(() =>
590
+ z.enum(["external", "protonpass", "keeper", "bitwarden"]),
591
+ );
592
+ export type ExternalVaultProviderKind = z.infer<typeof ExternalVaultProviderKind>;
593
+
594
+ /** Write-only setup material. Never included in connection summaries or logs. */
595
+ export const VaultProviderCredentials = /* @__PURE__ */ defineSchema(() =>
596
+ z.discriminatedUnion("provider", [
597
+ z
598
+ .object({
599
+ provider: z.literal("external"),
600
+ endpoint: z.string().url().max(2_048),
601
+ signingSecret: z.string().min(32).max(4_096),
602
+ })
603
+ .strict(),
604
+ z
605
+ .object({
606
+ provider: z.literal("bitwarden"),
607
+ endpoint: z.string().url().max(2_048),
608
+ signingSecret: z.string().min(32).max(4_096),
609
+ })
610
+ .strict(),
611
+ z
612
+ .object({
613
+ provider: z.literal("protonpass"),
614
+ token: z.string().min(16).max(4_096),
615
+ })
616
+ .strict(),
617
+ z
618
+ .object({
619
+ provider: z.literal("keeper"),
620
+ oneTimeToken: z.string().min(16).max(4_096),
621
+ /** Optional region host for tokens that do not encode one. */
622
+ hostname: z.string().max(253).optional(),
623
+ })
624
+ .strict(),
625
+ ]),
626
+ );
627
+ export type VaultProviderCredentials = z.infer<typeof VaultProviderCredentials>;
628
+
629
+ export const InstallVaultProviderRequest = /* @__PURE__ */ defineSchema(() =>
630
+ z
631
+ .object({
632
+ credentials: VaultProviderCredentials,
633
+ ownership: z.enum(["user", "workspace", "organization"]),
634
+ label: z.string().trim().min(1).max(120).optional(),
635
+ })
636
+ .strict(),
637
+ );
638
+ export type InstallVaultProviderRequest = z.infer<typeof InstallVaultProviderRequest>;
639
+
640
+ export const ReplaceVaultProviderCredentialsRequest = /* @__PURE__ */ defineSchema(() =>
641
+ z.object({ credentials: VaultProviderCredentials }).strict(),
642
+ );
643
+ export type ReplaceVaultProviderCredentialsRequest = z.infer<
644
+ typeof ReplaceVaultProviderCredentialsRequest
645
+ >;
646
+
647
+ /** Includes legacy 1Password connections; existing 1Password routes remain supported. */
648
+ export const VaultProviderConnectionSummary = /* @__PURE__ */ defineSchema(() =>
649
+ z.object({
650
+ id: z.string().uuid(),
651
+ provider: z.enum(["onepassword", "external", "protonpass", "keeper", "bitwarden"]),
652
+ ownership: z.enum(["user", "workspace", "organization"]),
653
+ accountName: z.string().nullable(),
654
+ label: z.string().nullable(),
655
+ verifiedAt: z.string(),
656
+ createdAt: z.string(),
657
+ createdBySubjectId: z.string().nullable(),
658
+ canManage: z.boolean(),
659
+ operations: VaultProviderOperations,
660
+ /** Only 1Password uses a plan tier. */
661
+ planTier: z.enum(["family", "teams", "business"]).optional(),
662
+ /** Unavailable means this deployment cannot run the adapter, not bad credentials. */
663
+ available: z.boolean(),
664
+ /** Setup material is saved, but provider verification has not completed. */
665
+ verificationStatus: z.enum(["ready", "pending"]).optional(),
666
+ }),
667
+ );
668
+ export type VaultProviderConnectionSummary = z.infer<typeof VaultProviderConnectionSummary>;
669
+
670
+ /** Deployment configuration, independent of whether anyone has connected yet. */
671
+ export const VaultProviderAvailability = /* @__PURE__ */ defineSchema(() =>
672
+ z.object({
673
+ provider: VaultProviderConnectionSummary.shape.provider,
674
+ available: z.boolean(),
675
+ reason: z.enum(["not_enabled"]).nullable(),
676
+ }),
677
+ );
678
+ export type VaultProviderAvailability = z.infer<typeof VaultProviderAvailability>;
679
+
680
+ export const ListVaultProviderConnectionsResponse = /* @__PURE__ */ defineSchema(() =>
681
+ z.object({
682
+ connections: z.array(VaultProviderConnectionSummary),
683
+ /** Additive: older servers may omit this metadata-only deployment catalog. */
684
+ providers: z.array(VaultProviderAvailability).optional(),
685
+ }),
686
+ );
687
+ export type ListVaultProviderConnectionsResponse = z.infer<
688
+ typeof ListVaultProviderConnectionsResponse
689
+ >;
690
+
691
+ export const InstallVaultProviderResponse = /* @__PURE__ */ defineSchema(() =>
692
+ z.object({
693
+ connectionId: z.string().uuid(),
694
+ accountName: z.string().nullable(),
695
+ provider: ExternalVaultProviderKind,
696
+ operations: VaultProviderOperations,
697
+ vaults: z.array(ProviderVaultMeta),
698
+ /** Retry verification on this connection; never replay a consumed bootstrap token. */
699
+ discoveryPending: z.boolean().optional(),
700
+ errorCode: z.string().max(100).optional(),
701
+ }),
702
+ );
703
+ export type InstallVaultProviderResponse = z.infer<typeof InstallVaultProviderResponse>;
704
+
705
+ export const DisconnectVaultProviderResponse = /* @__PURE__ */ defineSchema(() =>
706
+ z.object({ unlinkedVaultIds: z.array(z.string().uuid()) }),
707
+ );
708
+ export type DisconnectVaultProviderResponse = z.infer<typeof DisconnectVaultProviderResponse>;
709
+
545
710
  export const LinkProviderVaultRequest = /* @__PURE__ */ defineSchema(() =>
546
711
  z
547
712
  .object({
548
- provider: z.enum(["onepassword", "host"]),
549
- /** Required for onepassword. */
713
+ provider: z.enum(["onepassword", "host", "external", "protonpass", "keeper", "bitwarden"]),
714
+ /** Required except for an in-process host provider. */
550
715
  connectionId: z.string().uuid().optional(),
551
716
  externalVaultId: z.string(),
552
717
  ownerKind: z.enum(["user", "workspace", "organization"]),
@@ -593,6 +758,9 @@ export const VaultErrorCode = /* @__PURE__ */ defineSchema(() =>
593
758
  "provider_rate_limited",
594
759
  "provider_unavailable",
595
760
  "provider_conflict",
761
+ "provider_locked",
762
+ "provider_inventory_incomplete",
763
+ "provider_outcome_unknown",
596
764
  "variable_sets_removed",
597
765
  "secret_save_forbidden",
598
766
  "invalid_secret_name",
@@ -637,6 +805,9 @@ export const VAULT_ERROR_HTTP_STATUS: Readonly<Record<VaultErrorCode, number>> =
637
805
  provider_rate_limited: 429,
638
806
  provider_auth_invalid: 401,
639
807
  provider_auth_expired: 401,
808
+ provider_locked: 423,
809
+ provider_inventory_incomplete: 503,
810
+ provider_outcome_unknown: 503,
640
811
  };
641
812
 
642
813
  // ---------------------------------------------------------------------------
@@ -668,6 +839,8 @@ export const SecretSearchInput = /* @__PURE__ */ defineSchema(() =>
668
839
  limit: z.number().int().min(1).max(VAULT_LIMITS.searchResultsMax).default(20),
669
840
  /** `nextCursor` from the previous call with the same filters. */
670
841
  cursor: z.string().max(VAULT_LIMITS.searchCursorMaxChars).optional(),
842
+ /** Refresh provider metadata and subsequent value reads; never bypass rate limits. */
843
+ refresh: z.boolean().optional(),
671
844
  })
672
845
  .strict(),
673
846
  );
@@ -705,6 +878,7 @@ export const SecretSearchVault = /* @__PURE__ */ defineSchema(() =>
705
878
  source: VaultSource,
706
879
  mode: VaultMode,
707
880
  itemCount: z.number().int().nonnegative(),
881
+ freshness: VaultProviderFreshness.optional(),
708
882
  }),
709
883
  );
710
884
  export type SecretSearchVault = z.infer<typeof SecretSearchVault>;
@@ -716,6 +890,17 @@ export const SecretSearchOutput = /* @__PURE__ */ defineSchema(() =>
716
890
  nextCursor: z.string().nullable(),
717
891
  /** Every vault the caller can reach, on the first page only. */
718
892
  vaults: z.array(SecretSearchVault).optional(),
893
+ /** False when a reachable provider could not be checked; empty items are not proof of absence. */
894
+ complete: z.boolean().optional(),
895
+ /** Included on every page so failures are not lost after page one. */
896
+ sources: z
897
+ .array(
898
+ z.object({
899
+ vaultId: z.string().uuid(),
900
+ freshness: VaultProviderFreshness,
901
+ }),
902
+ )
903
+ .optional(),
719
904
  }),
720
905
  );
721
906
  export type SecretSearchOutput = z.infer<typeof SecretSearchOutput>;