@1password/sdk 0.4.1 → 0.5.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/README.md +8 -1
- package/dist/client_builder.js +9 -1
- package/dist/configuration.d.ts +5 -3
- package/dist/configuration.js +1 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +16 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +10 -1
- package/dist/shared_lib_core.d.ts +1 -0
- package/dist/shared_lib_core.js +6 -0
- package/dist/types.d.ts +12 -4
- package/dist/types.js +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ You can choose between two [authentication methods](https://developer.1password.
|
|
|
22
22
|
|
|
23
23
|
### Option 1: 1Password desktop app
|
|
24
24
|
|
|
25
|
-
[1Password desktop app authentication](https://developer.1password.com/docs/sdks/concepts#1password-desktop-app) is best for local integrations that require minimal setup from end users and sensitive workflows that require human-in-the-loop approval.
|
|
25
|
+
[1Password desktop app authentication](https://developer.1password.com/docs/sdks/concepts#1password-desktop-app) is best for local integrations that require minimal setup from end users and sensitive workflows that require human-in-the-loop approval.
|
|
26
26
|
|
|
27
27
|
1. Install the [1Password desktop app](https://1password.com/downloads/) and sign in to your account in the app.
|
|
28
28
|
2. Select your account or collection at the top of the sidebar, then navigate to **Settings** > **Developer**.
|
|
@@ -206,9 +206,16 @@ Inside `createClient()`, set `integrationName` to the name of your application a
|
|
|
206
206
|
### Authentication
|
|
207
207
|
|
|
208
208
|
- [x] [1Password Service Accounts](https://developer.1password.com/docs/sdks/concepts#1password-service-account)
|
|
209
|
+
- [x] [Workload identity](#workload-identity-public-preview) (public preview)
|
|
209
210
|
- [x] [User authentication](https://developer.1password.com/docs/sdks/concepts#1password-desktop-app)
|
|
210
211
|
- [ ] 1Password Connect. For now, use [1Password/connect-sdk-js](https://github.com/1Password/connect-sdk-js).
|
|
211
212
|
|
|
213
|
+
### Workload identity (public preview)
|
|
214
|
+
|
|
215
|
+
> **Public Preview** This feature is currently in *public preview*. Please see documentation [here](https://www.1password.dev/environments/credential-broker).
|
|
216
|
+
|
|
217
|
+
Instead of a service account token, you can authenticate a workload by providing an OIDC token fetcher and your workload details. The SDK calls your `oidcFetcher` to obtain a token when it needs one.
|
|
218
|
+
|
|
212
219
|
## 📖 Learn more
|
|
213
220
|
|
|
214
221
|
- [Load secrets](https://developer.1password.com/docs/sdks/load-secrets)
|
package/dist/client_builder.js
CHANGED
|
@@ -22,11 +22,19 @@ const finalizationRegistry = new FinalizationRegistry((heldClient) => {
|
|
|
22
22
|
* @returns The authenticated 1Password SDK client.
|
|
23
23
|
*/
|
|
24
24
|
const createClientWithCore = (config, core) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
if (!config.auth && !config.oidcFetcher) {
|
|
26
|
+
throw new Error("createClient requires either `auth` (service account token) or `oidcFetcher` (workload identity).");
|
|
27
|
+
}
|
|
28
|
+
if (config.oidcFetcher && !config.workloadDetails) {
|
|
29
|
+
throw new Error("`oidcFetcher` (workload identity) requires `workloadDetails` to be set.");
|
|
30
|
+
}
|
|
25
31
|
const authConfig = (0, configuration_js_1.clientAuthConfig)(config);
|
|
26
32
|
if (authConfig.accountName) {
|
|
27
33
|
core.setInner(new shared_lib_core_js_1.SharedLibCore(authConfig.accountName));
|
|
28
34
|
}
|
|
29
|
-
const clientId =
|
|
35
|
+
const clientId = config.oidcFetcher
|
|
36
|
+
? yield core.initClientOidc(authConfig, config.oidcFetcher)
|
|
37
|
+
: yield core.initClient(authConfig);
|
|
30
38
|
const inner = new core_js_1.InnerClient(parseInt(clientId, 10), core, authConfig);
|
|
31
39
|
const client = new client_js_1.Client(inner);
|
|
32
40
|
// Cleans up associated memory from core when client instance goes out of scope.
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ClientAuthConfig } from "./core.js";
|
|
1
|
+
import { ClientAuthConfig, WorkloadDetails } from "./core.js";
|
|
2
2
|
export declare const LANGUAGE = "JS";
|
|
3
|
-
export declare const VERSION = "
|
|
3
|
+
export declare const VERSION = "0050002";
|
|
4
4
|
export interface ClientConfiguration {
|
|
5
|
-
auth
|
|
5
|
+
auth?: Auth;
|
|
6
6
|
integrationName: string;
|
|
7
7
|
integrationVersion: string;
|
|
8
|
+
oidcFetcher?: (audience: string) => Promise<string>;
|
|
9
|
+
workloadDetails?: WorkloadDetails;
|
|
8
10
|
}
|
|
9
11
|
type Auth = string | DesktopAuth;
|
|
10
12
|
/**
|
package/dist/configuration.js
CHANGED
package/dist/core.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface Core {
|
|
|
6
6
|
* Allocates a new authenticated client and returns its id.
|
|
7
7
|
*/
|
|
8
8
|
initClient(config: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Allocates a new authenticated client using an OIDC token fetcher and returns its id.
|
|
11
|
+
*/
|
|
12
|
+
initClientOidc(config: string, fetcher: (audience: string) => Promise<string>): Promise<string>;
|
|
9
13
|
/**
|
|
10
14
|
* Calls async business logic from a given client and returns the result.
|
|
11
15
|
*/
|
|
@@ -30,6 +34,14 @@ export interface ClientAuthConfig {
|
|
|
30
34
|
architecture: string;
|
|
31
35
|
serviceAccountToken?: string;
|
|
32
36
|
accountName?: string;
|
|
37
|
+
workloadDetails?: WorkloadDetails;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Contains workload authentication details for OIDC-based workload identity.
|
|
41
|
+
*/
|
|
42
|
+
export interface WorkloadDetails {
|
|
43
|
+
customerManagedSecret: string;
|
|
44
|
+
workloadUuid: string;
|
|
33
45
|
}
|
|
34
46
|
/**
|
|
35
47
|
* Contains the information sent to the SDK core when you call (invoke) a function.
|
|
@@ -64,6 +76,7 @@ export interface Parameters {
|
|
|
64
76
|
}
|
|
65
77
|
export declare class WasmCore implements Core {
|
|
66
78
|
initClient(config: string): Promise<string>;
|
|
79
|
+
initClientOidc(config: string, fetcher: (audience: string) => Promise<string>): Promise<string>;
|
|
67
80
|
invoke(config: string): Promise<string>;
|
|
68
81
|
releaseClient(clientId: string): void;
|
|
69
82
|
}
|
|
@@ -75,6 +88,7 @@ export declare class SharedCore {
|
|
|
75
88
|
constructor();
|
|
76
89
|
setInner(core: Core): void;
|
|
77
90
|
initClient(config: ClientAuthConfig): Promise<string>;
|
|
91
|
+
initClientOidc(config: ClientAuthConfig, fetcher: (audience: string) => Promise<string>): Promise<string>;
|
|
78
92
|
invoke(config: InvokeConfig): Promise<string>;
|
|
79
93
|
invoke_sync(config: InvokeConfig): string;
|
|
80
94
|
releaseClient(clientId: number): void;
|
package/dist/core.js
CHANGED
|
@@ -28,6 +28,16 @@ class WasmCore {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
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
|
+
}
|
|
31
41
|
invoke(config) {
|
|
32
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
43
|
try {
|
|
@@ -64,6 +74,12 @@ class SharedCore {
|
|
|
64
74
|
return this.inner.initClient(serializedConfig);
|
|
65
75
|
});
|
|
66
76
|
}
|
|
77
|
+
initClientOidc(config, fetcher) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const serializedConfig = JSON.stringify(config);
|
|
80
|
+
return this.inner.initClientOidc(serializedConfig, fetcher);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
67
83
|
invoke(config) {
|
|
68
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
85
|
const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
|
package/dist/errors.d.ts
CHANGED
|
@@ -6,4 +6,8 @@ export declare class RateLimitExceededError extends Error {
|
|
|
6
6
|
message: string;
|
|
7
7
|
constructor(message: string);
|
|
8
8
|
}
|
|
9
|
+
export declare class AuthExpiredError extends Error {
|
|
10
|
+
message: string;
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
9
13
|
export declare const throwError: (errString: string) => never;
|
package/dist/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by op-codegen - DO NOT EDIT MANUALLY
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.throwError = exports.RateLimitExceededError = exports.DesktopSessionExpiredError = void 0;
|
|
4
|
+
exports.throwError = exports.AuthExpiredError = exports.RateLimitExceededError = exports.DesktopSessionExpiredError = void 0;
|
|
5
5
|
class DesktopSessionExpiredError extends Error {
|
|
6
6
|
constructor(message) {
|
|
7
7
|
super();
|
|
@@ -16,6 +16,13 @@ class RateLimitExceededError extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.RateLimitExceededError = RateLimitExceededError;
|
|
19
|
+
class AuthExpiredError extends Error {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super();
|
|
22
|
+
this.message = message;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.AuthExpiredError = AuthExpiredError;
|
|
19
26
|
const throwError = (errString) => {
|
|
20
27
|
let err;
|
|
21
28
|
try {
|
|
@@ -29,6 +36,8 @@ const throwError = (errString) => {
|
|
|
29
36
|
throw new DesktopSessionExpiredError(err.message);
|
|
30
37
|
case "RateLimitExceeded":
|
|
31
38
|
throw new RateLimitExceededError(err.message);
|
|
39
|
+
case "AuthExpired":
|
|
40
|
+
throw new AuthExpiredError(err.message);
|
|
32
41
|
default:
|
|
33
42
|
throw new Error(err.message);
|
|
34
43
|
}
|
|
@@ -11,6 +11,7 @@ export declare class SharedLibCore implements Core {
|
|
|
11
11
|
*/
|
|
12
12
|
private callSharedLibrary;
|
|
13
13
|
initClient(config: string): Promise<string>;
|
|
14
|
+
initClientOidc(config: string, _fetcher: (audience: string) => Promise<string>): Promise<string>;
|
|
14
15
|
invoke(invokeConfigBytes: string): Promise<string>;
|
|
15
16
|
releaseClient(clientId: string): void;
|
|
16
17
|
}
|
package/dist/shared_lib_core.js
CHANGED
|
@@ -163,6 +163,12 @@ class SharedLibCore {
|
|
|
163
163
|
return this.callSharedLibrary(config, "init_client");
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
167
|
+
initClientOidc(config, _fetcher) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
throw new Error("OIDC authentication is not supported with desktop auth");
|
|
170
|
+
});
|
|
171
|
+
}
|
|
166
172
|
invoke(invokeConfigBytes) {
|
|
167
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
174
|
return this.callSharedLibrary(invokeConfigBytes, "invoke");
|
package/dist/types.d.ts
CHANGED
|
@@ -18,7 +18,14 @@ export interface DocumentCreateParams {
|
|
|
18
18
|
/** The content of the file */
|
|
19
19
|
content: Uint8Array;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* One environment variable resolved by the credential broker.
|
|
23
|
+
*
|
|
24
|
+
* Shared between the Environments API (`GetVariablesResponse`) and the
|
|
25
|
+
* Credentials API (`CredentialResponse::Environment`, gated on
|
|
26
|
+
* `brokered-access`), since both surfaces read from the same credential
|
|
27
|
+
* broker enclave endpoint.
|
|
28
|
+
*/
|
|
22
29
|
export interface EnvironmentVariable {
|
|
23
30
|
/** An environment variable's name */
|
|
24
31
|
name: string;
|
|
@@ -107,7 +114,8 @@ export declare enum GroupState {
|
|
|
107
114
|
}
|
|
108
115
|
export declare enum VaultAccessorType {
|
|
109
116
|
User = "user",
|
|
110
|
-
Group = "group"
|
|
117
|
+
Group = "group",
|
|
118
|
+
Broker = "broker"
|
|
111
119
|
}
|
|
112
120
|
/** Represents the vault access information. */
|
|
113
121
|
export interface VaultAccess {
|
|
@@ -619,7 +627,7 @@ export interface Vault {
|
|
|
619
627
|
activeItemCount: number;
|
|
620
628
|
/** The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). */
|
|
621
629
|
contentVersion: number;
|
|
622
|
-
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its
|
|
630
|
+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its name or icon. */
|
|
623
631
|
attributeVersion: number;
|
|
624
632
|
/** The access information associated with the vault. */
|
|
625
633
|
access?: VaultAccess[];
|
|
@@ -651,7 +659,7 @@ export interface VaultOverview {
|
|
|
651
659
|
activeItemCount: number;
|
|
652
660
|
/** The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). */
|
|
653
661
|
contentVersion: number;
|
|
654
|
-
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its
|
|
662
|
+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its name or icon. */
|
|
655
663
|
attributeVersion: number;
|
|
656
664
|
/** The time the vault was created at */
|
|
657
665
|
createdAt: Date;
|
package/dist/types.js
CHANGED
|
@@ -57,6 +57,7 @@ var VaultAccessorType;
|
|
|
57
57
|
(function (VaultAccessorType) {
|
|
58
58
|
VaultAccessorType["User"] = "user";
|
|
59
59
|
VaultAccessorType["Group"] = "group";
|
|
60
|
+
VaultAccessorType["Broker"] = "broker";
|
|
60
61
|
})(VaultAccessorType || (exports.VaultAccessorType = VaultAccessorType = {}));
|
|
61
62
|
var ItemCategory;
|
|
62
63
|
(function (ItemCategory) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
2
|
-
export declare const SDK_BUILD_NUMBER = "
|
|
1
|
+
export declare const SDK_VERSION = "0.5.0";
|
|
2
|
+
export declare const SDK_BUILD_NUMBER = "0050002";
|
package/dist/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SDK_BUILD_NUMBER = exports.SDK_VERSION = void 0;
|
|
4
|
-
exports.SDK_VERSION = "0.
|
|
5
|
-
exports.SDK_BUILD_NUMBER = "
|
|
6
|
-
const SDK_CORE_VERSION = "0.
|
|
4
|
+
exports.SDK_VERSION = "0.5.0";
|
|
5
|
+
exports.SDK_BUILD_NUMBER = "0050002";
|
|
6
|
+
const SDK_CORE_VERSION = "0.5.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1password/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The 1Password JavaScript SDK offers programmatic read access to your secrets in 1Password in an interface native to JavaScript. The SDK currently supports `Node.JS`",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"main": "./dist/sdk.js",
|
|
27
27
|
"types": "./dist/sdk.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@1password/sdk-core": "0.
|
|
29
|
+
"@1password/sdk-core": "0.5.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@1password/eslint-config": "^4.0.0",
|