@1password/sdk 0.4.1-beta.1 → 0.5.0-beta.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.
- package/README.md +7 -0
- 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/shared_lib_core.d.ts +1 -0
- package/dist/shared_lib_core.js +6 -0
- package/dist/types.d.ts +4 -3
- 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
|
@@ -135,9 +135,16 @@ Field types:
|
|
|
135
135
|
### Authentication
|
|
136
136
|
|
|
137
137
|
- [x] [1Password Service Accounts](https://developer.1password.com/docs/service-accounts/get-started/)
|
|
138
|
+
- [x] [Workload identity](#workload-identity-beta) (beta)
|
|
138
139
|
- [ ] User authentication
|
|
139
140
|
- [ ] 1Password Connect. For now, use [1Password/connect-sdk-js](https://github.com/1Password/connect-sdk-js).
|
|
140
141
|
|
|
142
|
+
### Workload identity (beta)
|
|
143
|
+
|
|
144
|
+
> **Private beta.** Currently available for GitHub Actions via 1Password Credential Broker.
|
|
145
|
+
|
|
146
|
+
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.
|
|
147
|
+
|
|
141
148
|
## 📖 Learn more
|
|
142
149
|
|
|
143
150
|
- [Load secrets with 1Password SDKs](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 = "0050001";
|
|
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);
|
|
@@ -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
|
@@ -107,7 +107,8 @@ export declare enum GroupState {
|
|
|
107
107
|
}
|
|
108
108
|
export declare enum VaultAccessorType {
|
|
109
109
|
User = "user",
|
|
110
|
-
Group = "group"
|
|
110
|
+
Group = "group",
|
|
111
|
+
Broker = "broker"
|
|
111
112
|
}
|
|
112
113
|
/** Represents the vault access information. */
|
|
113
114
|
export interface VaultAccess {
|
|
@@ -619,7 +620,7 @@ export interface Vault {
|
|
|
619
620
|
activeItemCount: number;
|
|
620
621
|
/** 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
622
|
contentVersion: number;
|
|
622
|
-
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its
|
|
623
|
+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its name or icon. */
|
|
623
624
|
attributeVersion: number;
|
|
624
625
|
/** The access information associated with the vault. */
|
|
625
626
|
access?: VaultAccess[];
|
|
@@ -651,7 +652,7 @@ export interface VaultOverview {
|
|
|
651
652
|
activeItemCount: number;
|
|
652
653
|
/** 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
654
|
contentVersion: number;
|
|
654
|
-
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its
|
|
655
|
+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its name or icon. */
|
|
655
656
|
attributeVersion: number;
|
|
656
657
|
/** The time the vault was created at */
|
|
657
658
|
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-beta.1";
|
|
2
|
+
export declare const SDK_BUILD_NUMBER = "0050001";
|
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-beta.1";
|
|
5
|
+
exports.SDK_BUILD_NUMBER = "0050001";
|
|
6
|
+
const SDK_CORE_VERSION = "0.5.0-beta.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1password/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.1",
|
|
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-beta.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@1password/eslint-config": "^4.0.0",
|