@1password/sdk 0.0.0-credential-broker-dev-preview

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.
Files changed (44) hide show
  1. package/README.md +220 -0
  2. package/dist/client.d.ts +23 -0
  3. package/dist/client.js +32 -0
  4. package/dist/client_builder.d.ts +18 -0
  5. package/dist/client_builder.js +64 -0
  6. package/dist/configuration.d.ts +33 -0
  7. package/dist/configuration.js +58 -0
  8. package/dist/core.d.ts +115 -0
  9. package/dist/core.js +154 -0
  10. package/dist/credential_broker.d.ts +28 -0
  11. package/dist/credential_broker.js +31 -0
  12. package/dist/credential_broker_access_requests.d.ts +43 -0
  13. package/dist/credential_broker_access_requests.js +78 -0
  14. package/dist/credential_broker_environment_variables.d.ts +33 -0
  15. package/dist/credential_broker_environment_variables.js +58 -0
  16. package/dist/credential_broker_logins.d.ts +38 -0
  17. package/dist/credential_broker_logins.js +77 -0
  18. package/dist/environments.d.ts +82 -0
  19. package/dist/environments.js +132 -0
  20. package/dist/errors.d.ts +13 -0
  21. package/dist/errors.js +45 -0
  22. package/dist/groups.d.ts +19 -0
  23. package/dist/groups.js +54 -0
  24. package/dist/items.d.ts +89 -0
  25. package/dist/items.js +216 -0
  26. package/dist/items_files.d.ts +40 -0
  27. package/dist/items_files.js +116 -0
  28. package/dist/items_shares.d.ts +32 -0
  29. package/dist/items_shares.js +95 -0
  30. package/dist/sdk.d.ts +24 -0
  31. package/dist/sdk.js +57 -0
  32. package/dist/secrets.d.ts +36 -0
  33. package/dist/secrets.js +107 -0
  34. package/dist/shared_lib_core.d.ts +17 -0
  35. package/dist/shared_lib_core.js +183 -0
  36. package/dist/types.d.ts +972 -0
  37. package/dist/types.js +279 -0
  38. package/dist/vaults.d.ts +83 -0
  39. package/dist/vaults.js +209 -0
  40. package/dist/version.d.ts +2 -0
  41. package/dist/version.js +6 -0
  42. package/dist/web.d.ts +11 -0
  43. package/dist/web.js +55 -0
  44. package/package.json +54 -0
package/dist/core.js ADDED
@@ -0,0 +1,154 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StandardClient = exports.InnerClient = exports.SharedCore = exports.WasmCore = void 0;
13
+ const sdk_core_1 = require("@1password/sdk-core");
14
+ const types_1 = require("./types");
15
+ const errors_1 = require("./errors");
16
+ // In empirical tests, we determined that maximum message size that can cross the FFI boundary
17
+ // is ~64MB. Past this limit, the wasm-bingen FFI will throw an error and the program will crash.
18
+ // We set the limit to 50MB to be safe, to be reconsidered upon further testing.
19
+ const messageLimit = 50 * 1024 * 1024;
20
+ class WasmCore {
21
+ initClient(config) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ try {
24
+ return yield (0, sdk_core_1.init_client)(config);
25
+ }
26
+ catch (e) {
27
+ (0, errors_1.throwError)(e);
28
+ }
29
+ });
30
+ }
31
+ initClientOidc(config, fetcher) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ try {
34
+ return yield (0, sdk_core_1.init_client_oidc)(config, fetcher);
35
+ }
36
+ catch (e) {
37
+ (0, errors_1.throwError)(e);
38
+ }
39
+ });
40
+ }
41
+ invoke(config) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ return yield (0, sdk_core_1.invoke)(config);
45
+ }
46
+ catch (e) {
47
+ (0, errors_1.throwError)(e);
48
+ }
49
+ });
50
+ }
51
+ releaseClient(clientId) {
52
+ try {
53
+ (0, sdk_core_1.release_client)(clientId);
54
+ }
55
+ catch (e) {
56
+ console.warn("failed to release client:", e);
57
+ }
58
+ }
59
+ }
60
+ exports.WasmCore = WasmCore;
61
+ /**
62
+ * An implementation of the `Core` interface that shares resources across all clients.
63
+ */
64
+ class SharedCore {
65
+ constructor() {
66
+ this.inner = new WasmCore();
67
+ }
68
+ setInner(core) {
69
+ this.inner = core;
70
+ }
71
+ initClient(config) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const serializedConfig = JSON.stringify(config);
74
+ return this.inner.initClient(serializedConfig);
75
+ });
76
+ }
77
+ initClientOidc(config, fetcher) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ // The oidcFetcher is passed separately and dropped by JSON serialization.
80
+ const serializedConfig = JSON.stringify(config);
81
+ return this.inner.initClientOidc(serializedConfig, fetcher);
82
+ });
83
+ }
84
+ invoke(config) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
87
+ // Encoding to bytes as JS uses UTF-16 under the hood, but the messages
88
+ // that are sent across the FFI boundary are encoded in UTF-8.
89
+ if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
90
+ (0, errors_1.throwError)(`message size exceeds the limit of ${messageLimit} bytes, please contact 1Password at support@1password.com or https://developer.1password.com/joinslack if you need help."`);
91
+ }
92
+ return this.inner.invoke(serializedConfig);
93
+ });
94
+ }
95
+ invoke_sync(config) {
96
+ const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
97
+ // Encoding to bytes as JS uses UTF-16 under the hood, but the messages
98
+ // that are sent across the FFI boundary are encoded in UTF-8.
99
+ if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
100
+ (0, errors_1.throwError)(`message size exceeds the limit of ${messageLimit} bytes, please contact 1Password at support@1password.com or https://developer.1password.com/joinslack if you need help.`);
101
+ }
102
+ return (0, sdk_core_1.invoke_sync)(serializedConfig);
103
+ }
104
+ releaseClient(clientId) {
105
+ const serializedId = JSON.stringify(clientId);
106
+ this.inner.releaseClient(serializedId);
107
+ }
108
+ }
109
+ exports.SharedCore = SharedCore;
110
+ /**
111
+ * Represents the client instance on which a call is made.
112
+ */
113
+ class InnerClient {
114
+ constructor(id, core) {
115
+ this.id = id;
116
+ this.core = core;
117
+ }
118
+ invoke(config) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ return yield this.core.invoke(config);
121
+ });
122
+ }
123
+ }
124
+ exports.InnerClient = InnerClient;
125
+ /**
126
+ * A token- or desktop-authenticated client. It retains the auth config so it can
127
+ * transparently re-initialize after a desktop session expires.
128
+ */
129
+ class StandardClient extends InnerClient {
130
+ constructor(id, core, config) {
131
+ super(id, core);
132
+ this.config = config;
133
+ }
134
+ invoke(config) {
135
+ const _super = Object.create(null, {
136
+ invoke: { get: () => super.invoke }
137
+ });
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ try {
140
+ return yield _super.invoke.call(this, config);
141
+ }
142
+ catch (err) {
143
+ if (err instanceof errors_1.DesktopSessionExpiredError) {
144
+ const newId = yield this.core.initClient(this.config);
145
+ this.id = parseInt(newId, 10);
146
+ config.invocation.clientId = this.id;
147
+ return yield _super.invoke.call(this, config);
148
+ }
149
+ throw err;
150
+ }
151
+ });
152
+ }
153
+ }
154
+ exports.StandardClient = StandardClient;
@@ -0,0 +1,28 @@
1
+ import { InnerClient } from "./core.js";
2
+ import { CredentialBrokerEnvironmentVariablesApi } from "./credential_broker_environment_variables.js";
3
+ import { CredentialBrokerLoginsApi } from "./credential_broker_logins.js";
4
+ import { CredentialBrokerAccessRequestsApi } from "./credential_broker_access_requests.js";
5
+ /**
6
+ * Root namespace for the 1Password Credential Broker.
7
+ *
8
+ * Marker trait — no methods of its own. Each supported credential kind is a
9
+ * nested API accessed as `client.credential_broker.<kind>`
10
+ * ([`EnvironmentVariables`] and [`Logins`] today; `ApiKey`, ... as they land).
11
+ */
12
+ export interface CredentialBrokerApi {
13
+ environmentVariables: CredentialBrokerEnvironmentVariablesApi;
14
+ logins: CredentialBrokerLoginsApi;
15
+ }
16
+ export declare class CredentialBroker implements CredentialBrokerApi {
17
+ #private;
18
+ environmentVariables: CredentialBrokerEnvironmentVariablesApi;
19
+ logins: CredentialBrokerLoginsApi;
20
+ constructor(inner: InnerClient);
21
+ }
22
+ export interface OAuthCredentialBrokerApi extends CredentialBrokerApi {
23
+ accessRequests: CredentialBrokerAccessRequestsApi;
24
+ }
25
+ export declare class OAuthCredentialBroker extends CredentialBroker implements OAuthCredentialBrokerApi {
26
+ accessRequests: CredentialBrokerAccessRequestsApi;
27
+ constructor(inner: InnerClient);
28
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4
+ if (kind === "m") throw new TypeError("Private method is not writable");
5
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8
+ };
9
+ var _CredentialBroker_inner;
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.OAuthCredentialBroker = exports.CredentialBroker = void 0;
12
+ const credential_broker_environment_variables_js_1 = require("./credential_broker_environment_variables.js");
13
+ const credential_broker_logins_js_1 = require("./credential_broker_logins.js");
14
+ const credential_broker_access_requests_js_1 = require("./credential_broker_access_requests.js");
15
+ class CredentialBroker {
16
+ constructor(inner) {
17
+ _CredentialBroker_inner.set(this, void 0);
18
+ __classPrivateFieldSet(this, _CredentialBroker_inner, inner, "f");
19
+ this.environmentVariables = new credential_broker_environment_variables_js_1.CredentialBrokerEnvironmentVariables(inner);
20
+ this.logins = new credential_broker_logins_js_1.CredentialBrokerLogins(inner);
21
+ }
22
+ }
23
+ exports.CredentialBroker = CredentialBroker;
24
+ _CredentialBroker_inner = new WeakMap();
25
+ class OAuthCredentialBroker extends CredentialBroker {
26
+ constructor(inner) {
27
+ super(inner);
28
+ this.accessRequests = new credential_broker_access_requests_js_1.CredentialBrokerAccessRequests(inner);
29
+ }
30
+ }
31
+ exports.OAuthCredentialBroker = OAuthCredentialBroker;
@@ -0,0 +1,43 @@
1
+ import { InnerClient } from "./core.js";
2
+ import { AccessRequest, AccessRequestCreateParams, AccessRequestStatus } from "./types.js";
3
+ /**
4
+ * Create and poll credential-broker access requests: asking a target
5
+ * identity to grant this workload access to one or more credentials.
6
+ *
7
+ * Accessed as `client.credential_broker.access_requests` in the generated
8
+ * SDK bindings.
9
+ */
10
+ export interface CredentialBrokerAccessRequestsApi {
11
+ /**
12
+ * Register a new access request. The SDK mints the request id and
13
+ * per-entry ids, and derives the target identity from the
14
+ * authenticated workload.
15
+ *
16
+ * Only the non-sensitive half is registered server-side; the returned
17
+ * request is the full object with the presentation fields re-attached.
18
+ */
19
+ create(params: AccessRequestCreateParams): Promise<AccessRequest>;
20
+ /**
21
+ * Get the current status of an access request created by
22
+ * [`AccessRequests::create`].
23
+ */
24
+ getStatus(accessRequestId: string): Promise<AccessRequestStatus>;
25
+ }
26
+ export declare class CredentialBrokerAccessRequests implements CredentialBrokerAccessRequestsApi {
27
+ #private;
28
+ constructor(inner: InnerClient);
29
+ /**
30
+ * Register a new access request. The SDK mints the request id and
31
+ * per-entry ids, and derives the target identity from the
32
+ * authenticated workload.
33
+ *
34
+ * Only the non-sensitive half is registered server-side; the returned
35
+ * request is the full object with the presentation fields re-attached.
36
+ */
37
+ create(params: AccessRequestCreateParams): Promise<AccessRequest>;
38
+ /**
39
+ * Get the current status of an access request created by
40
+ * [`AccessRequests::create`].
41
+ */
42
+ getStatus(accessRequestId: string): Promise<AccessRequestStatus>;
43
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
18
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
19
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
20
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
21
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
22
+ };
23
+ var _CredentialBrokerAccessRequests_inner;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.CredentialBrokerAccessRequests = void 0;
26
+ const types_js_1 = require("./types.js");
27
+ class CredentialBrokerAccessRequests {
28
+ constructor(inner) {
29
+ _CredentialBrokerAccessRequests_inner.set(this, void 0);
30
+ __classPrivateFieldSet(this, _CredentialBrokerAccessRequests_inner, inner, "f");
31
+ }
32
+ /**
33
+ * Register a new access request. The SDK mints the request id and
34
+ * per-entry ids, and derives the target identity from the
35
+ * authenticated workload.
36
+ *
37
+ * Only the non-sensitive half is registered server-side; the returned
38
+ * request is the full object with the presentation fields re-attached.
39
+ */
40
+ create(params) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const invocationConfig = {
43
+ invocation: {
44
+ clientId: __classPrivateFieldGet(this, _CredentialBrokerAccessRequests_inner, "f").id,
45
+ parameters: {
46
+ name: "CredentialBrokerAccessRequestsCreate",
47
+ parameters: {
48
+ params,
49
+ },
50
+ },
51
+ },
52
+ };
53
+ return JSON.parse(yield __classPrivateFieldGet(this, _CredentialBrokerAccessRequests_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
54
+ });
55
+ }
56
+ /**
57
+ * Get the current status of an access request created by
58
+ * [`AccessRequests::create`].
59
+ */
60
+ getStatus(accessRequestId) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const invocationConfig = {
63
+ invocation: {
64
+ clientId: __classPrivateFieldGet(this, _CredentialBrokerAccessRequests_inner, "f").id,
65
+ parameters: {
66
+ name: "CredentialBrokerAccessRequestsGetStatus",
67
+ parameters: {
68
+ access_request_id: accessRequestId,
69
+ },
70
+ },
71
+ },
72
+ };
73
+ return JSON.parse(yield __classPrivateFieldGet(this, _CredentialBrokerAccessRequests_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
74
+ });
75
+ }
76
+ }
77
+ exports.CredentialBrokerAccessRequests = CredentialBrokerAccessRequests;
78
+ _CredentialBrokerAccessRequests_inner = new WeakMap();
@@ -0,0 +1,33 @@
1
+ import { InnerClient } from "./core.js";
2
+ import { CredentialReference, EnvironmentCredential } from "./types.js";
3
+ /**
4
+ * Read environment credentials — a bundle of environment variables — from
5
+ * the 1Password Credential Broker.
6
+ *
7
+ * Accessed as `client.credential_broker.environment_variables` in the generated SDK
8
+ * bindings.
9
+ */
10
+ export interface CredentialBrokerEnvironmentVariablesApi {
11
+ /**
12
+ * Fetch the environment credential identified by `credential_reference`.
13
+ *
14
+ * In addition to transport, keyset-decryption, and enclave errors surfaced as [Error::Internal],
15
+ * fails with [Error::InvalidCredentialReference] if the reference is malformed
16
+ * or does not name an environment credential, or with [Error::CredentialReferenceAccountMismatch]
17
+ * if it belongs to a different account than the authenticated client.
18
+ */
19
+ read(credentialReference: CredentialReference): Promise<EnvironmentCredential>;
20
+ }
21
+ export declare class CredentialBrokerEnvironmentVariables implements CredentialBrokerEnvironmentVariablesApi {
22
+ #private;
23
+ constructor(inner: InnerClient);
24
+ /**
25
+ * Fetch the environment credential identified by `credential_reference`.
26
+ *
27
+ * In addition to transport, keyset-decryption, and enclave errors surfaced as [Error::Internal],
28
+ * fails with [Error::InvalidCredentialReference] if the reference is malformed
29
+ * or does not name an environment credential, or with [Error::CredentialReferenceAccountMismatch]
30
+ * if it belongs to a different account than the authenticated client.
31
+ */
32
+ read(credentialReference: CredentialReference): Promise<EnvironmentCredential>;
33
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
18
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
19
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
20
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
21
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
22
+ };
23
+ var _CredentialBrokerEnvironmentVariables_inner;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.CredentialBrokerEnvironmentVariables = void 0;
26
+ const types_js_1 = require("./types.js");
27
+ class CredentialBrokerEnvironmentVariables {
28
+ constructor(inner) {
29
+ _CredentialBrokerEnvironmentVariables_inner.set(this, void 0);
30
+ __classPrivateFieldSet(this, _CredentialBrokerEnvironmentVariables_inner, inner, "f");
31
+ }
32
+ /**
33
+ * Fetch the environment credential identified by `credential_reference`.
34
+ *
35
+ * In addition to transport, keyset-decryption, and enclave errors surfaced as [Error::Internal],
36
+ * fails with [Error::InvalidCredentialReference] if the reference is malformed
37
+ * or does not name an environment credential, or with [Error::CredentialReferenceAccountMismatch]
38
+ * if it belongs to a different account than the authenticated client.
39
+ */
40
+ read(credentialReference) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const invocationConfig = {
43
+ invocation: {
44
+ clientId: __classPrivateFieldGet(this, _CredentialBrokerEnvironmentVariables_inner, "f").id,
45
+ parameters: {
46
+ name: "CredentialBrokerEnvironmentVariablesRead",
47
+ parameters: {
48
+ credential_reference: credentialReference,
49
+ },
50
+ },
51
+ },
52
+ };
53
+ return JSON.parse(yield __classPrivateFieldGet(this, _CredentialBrokerEnvironmentVariables_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
54
+ });
55
+ }
56
+ }
57
+ exports.CredentialBrokerEnvironmentVariables = CredentialBrokerEnvironmentVariables;
58
+ _CredentialBrokerEnvironmentVariables_inner = new WeakMap();
@@ -0,0 +1,38 @@
1
+ import { InnerClient } from "./core.js";
2
+ import { CredentialReference, LoginCredential, LoginDetails } from "./types.js";
3
+ /**
4
+ * Read login credentials from the 1Password Credential Broker.
5
+ * Accessed as `client.credential_broker.logins` in the generated SDK bindings.
6
+ */
7
+ export interface CredentialBrokerLoginsApi {
8
+ /**
9
+ * Fetch the login credential identified by `credential_reference`.
10
+ *
11
+ * In addition to transport, keyset-decryption, and enclave errors surfaced as [Error::Internal],
12
+ * fails with [Error::InvalidCredentialReference] if the reference is malformed
13
+ * or does not name a login credential, or with [Error::CredentialReferenceAccountMismatch]
14
+ * if it belongs to a different account than the authenticated client.
15
+ */
16
+ read(credentialReference: CredentialReference): Promise<LoginCredential>;
17
+ /**
18
+ * Fetch non-secret details for the login identified by `credential_reference`.
19
+ */
20
+ getDetails(credentialReference: CredentialReference): Promise<LoginDetails>;
21
+ }
22
+ export declare class CredentialBrokerLogins implements CredentialBrokerLoginsApi {
23
+ #private;
24
+ constructor(inner: InnerClient);
25
+ /**
26
+ * Fetch the login credential identified by `credential_reference`.
27
+ *
28
+ * In addition to transport, keyset-decryption, and enclave errors surfaced as [Error::Internal],
29
+ * fails with [Error::InvalidCredentialReference] if the reference is malformed
30
+ * or does not name a login credential, or with [Error::CredentialReferenceAccountMismatch]
31
+ * if it belongs to a different account than the authenticated client.
32
+ */
33
+ read(credentialReference: CredentialReference): Promise<LoginCredential>;
34
+ /**
35
+ * Fetch non-secret details for the login identified by `credential_reference`.
36
+ */
37
+ getDetails(credentialReference: CredentialReference): Promise<LoginDetails>;
38
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
18
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
19
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
20
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
21
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
22
+ };
23
+ var _CredentialBrokerLogins_inner;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.CredentialBrokerLogins = void 0;
26
+ const types_js_1 = require("./types.js");
27
+ class CredentialBrokerLogins {
28
+ constructor(inner) {
29
+ _CredentialBrokerLogins_inner.set(this, void 0);
30
+ __classPrivateFieldSet(this, _CredentialBrokerLogins_inner, inner, "f");
31
+ }
32
+ /**
33
+ * Fetch the login credential identified by `credential_reference`.
34
+ *
35
+ * In addition to transport, keyset-decryption, and enclave errors surfaced as [Error::Internal],
36
+ * fails with [Error::InvalidCredentialReference] if the reference is malformed
37
+ * or does not name a login credential, or with [Error::CredentialReferenceAccountMismatch]
38
+ * if it belongs to a different account than the authenticated client.
39
+ */
40
+ read(credentialReference) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const invocationConfig = {
43
+ invocation: {
44
+ clientId: __classPrivateFieldGet(this, _CredentialBrokerLogins_inner, "f").id,
45
+ parameters: {
46
+ name: "CredentialBrokerLoginsRead",
47
+ parameters: {
48
+ credential_reference: credentialReference,
49
+ },
50
+ },
51
+ },
52
+ };
53
+ return JSON.parse(yield __classPrivateFieldGet(this, _CredentialBrokerLogins_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
54
+ });
55
+ }
56
+ /**
57
+ * Fetch non-secret details for the login identified by `credential_reference`.
58
+ */
59
+ getDetails(credentialReference) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const invocationConfig = {
62
+ invocation: {
63
+ clientId: __classPrivateFieldGet(this, _CredentialBrokerLogins_inner, "f").id,
64
+ parameters: {
65
+ name: "CredentialBrokerLoginsGetDetails",
66
+ parameters: {
67
+ credential_reference: credentialReference,
68
+ },
69
+ },
70
+ },
71
+ };
72
+ return JSON.parse(yield __classPrivateFieldGet(this, _CredentialBrokerLogins_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
73
+ });
74
+ }
75
+ }
76
+ exports.CredentialBrokerLogins = CredentialBrokerLogins;
77
+ _CredentialBrokerLogins_inner = new WeakMap();
@@ -0,0 +1,82 @@
1
+ import { InnerClient } from "./core.js";
2
+ import { Environment, EnvironmentSecret, GetVariablesResponse } from "./types.js";
3
+ /**
4
+ * The Environments API holds all the operations the SDK client can perform
5
+ * on 1Password Environments and the secrets inside them.
6
+ */
7
+ export interface EnvironmentsApi {
8
+ /**
9
+ * Get environment variables belonging to an Environment.
10
+ */
11
+ getVariables(environmentId: string): Promise<GetVariablesResponse>;
12
+ /**
13
+ * Get a single secret from an Environment.
14
+ *
15
+ * `environment_name_id` accepts either the Environment's name or its
16
+ * ID; a name that matches more than one Environment is an error.
17
+ *
18
+ * `secret_name` is the name of the secret to get, matched
19
+ * case-insensitively; a name that matches more than one secret in the
20
+ * Environment is an error.
21
+ *
22
+ * `reveal` controls whether a concealed secret's value is returned;
23
+ * when `reveal` is `false`, a concealed value is withheld.
24
+ */
25
+ getSecret(environmentNameId: string, secretName: string, reveal: boolean): Promise<EnvironmentSecret>;
26
+ /**
27
+ * List all secrets in an Environment.
28
+ *
29
+ * `environment_name_id` accepts either the Environment's name or its
30
+ * ID; a name that matches more than one Environment is an error.
31
+ *
32
+ * `reveal` controls whether concealed secrets' values are returned;
33
+ * when `reveal` is `false`, concealed values are withheld.
34
+ */
35
+ listSecrets(environmentNameId: string, reveal: boolean): Promise<EnvironmentSecret[]>;
36
+ /**
37
+ * Create a new Environment.
38
+ *
39
+ * `environment_name` accepts a name for the new Environment. The name is
40
+ * trimmed. A name that is empty after trimming is an error.
41
+ */
42
+ create(environmentName: string): Promise<Environment>;
43
+ }
44
+ export declare class Environments implements EnvironmentsApi {
45
+ #private;
46
+ constructor(inner: InnerClient);
47
+ /**
48
+ * Get environment variables belonging to an Environment.
49
+ */
50
+ getVariables(environmentId: string): Promise<GetVariablesResponse>;
51
+ /**
52
+ * Get a single secret from an Environment.
53
+ *
54
+ * `environment_name_id` accepts either the Environment's name or its
55
+ * ID; a name that matches more than one Environment is an error.
56
+ *
57
+ * `secret_name` is the name of the secret to get, matched
58
+ * case-insensitively; a name that matches more than one secret in the
59
+ * Environment is an error.
60
+ *
61
+ * `reveal` controls whether a concealed secret's value is returned;
62
+ * when `reveal` is `false`, a concealed value is withheld.
63
+ */
64
+ getSecret(environmentNameId: string, secretName: string, reveal: boolean): Promise<EnvironmentSecret>;
65
+ /**
66
+ * List all secrets in an Environment.
67
+ *
68
+ * `environment_name_id` accepts either the Environment's name or its
69
+ * ID; a name that matches more than one Environment is an error.
70
+ *
71
+ * `reveal` controls whether concealed secrets' values are returned;
72
+ * when `reveal` is `false`, concealed values are withheld.
73
+ */
74
+ listSecrets(environmentNameId: string, reveal: boolean): Promise<EnvironmentSecret[]>;
75
+ /**
76
+ * Create a new Environment.
77
+ *
78
+ * `environment_name` accepts a name for the new Environment. The name is
79
+ * trimmed. A name that is empty after trimming is an error.
80
+ */
81
+ create(environmentName: string): Promise<Environment>;
82
+ }