From 29cf1a0ade8d6f9a75ec1d5d518b3035374907b3 Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Fri, 15 Mar 2024 15:52:31 +0100 Subject: [PATCH 1/6] Add example docs --- docs/.nojekyll | 1 + docs/README.md | 65 ++++++++++ docs/classes/client.Client.md | 45 +++++++ docs/classes/core.SharedCore.md | 103 +++++++++++++++ docs/classes/secrets.SecretsSource.md | 81 ++++++++++++ .../configuration.ClientConfiguration.md | 43 +++++++ docs/interfaces/configuration.InnerClient.md | 32 +++++ docs/interfaces/core.ClientAuthConfig.md | 120 ++++++++++++++++++ docs/interfaces/core.Core.md | 77 +++++++++++ docs/interfaces/core.InvokeConfig.md | 32 +++++ docs/interfaces/secrets.SecretsApi.md | 39 ++++++ docs/modules.md | 12 ++ docs/modules/client.md | 113 +++++++++++++++++ docs/modules/configuration.md | 10 ++ docs/modules/core.md | 15 +++ docs/modules/secrets.md | 13 ++ 16 files changed, 801 insertions(+) create mode 100644 docs/.nojekyll create mode 100644 docs/README.md create mode 100644 docs/classes/client.Client.md create mode 100644 docs/classes/core.SharedCore.md create mode 100644 docs/classes/secrets.SecretsSource.md create mode 100644 docs/interfaces/configuration.ClientConfiguration.md create mode 100644 docs/interfaces/configuration.InnerClient.md create mode 100644 docs/interfaces/core.ClientAuthConfig.md create mode 100644 docs/interfaces/core.Core.md create mode 100644 docs/interfaces/core.InvokeConfig.md create mode 100644 docs/interfaces/secrets.SecretsApi.md create mode 100644 docs/modules.md create mode 100644 docs/modules/client.md create mode 100644 docs/modules/configuration.md create mode 100644 docs/modules/core.md create mode 100644 docs/modules/secrets.md diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e2ac661 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..e063218 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,65 @@ +@1password/sdk / [Modules](modules.md) + +# 1Password JavaScript SDK + +> ❗ This project is still in its early, pre-alpha stages of development. Its stability is not yet fully assessed, and future iterations may bring backwards incompatible changes. Proceed with caution. + +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` and authentication with [1Password Service Accounts](https://developer.1password.com/docs/service-accounts/). + +### Get started + +To use the 1Password JavaScript SDK in your project: + +1. [Create a 1Password Service Account](https://developer.1password.com/docs/service-accounts/get-started/#create-a-service-account). Make sure to grant the service account access to the vaults where the secrets your project needs access to are stored. +2. Export your service account token to the `OP_SERVICE_ACCOUNT_TOKEN` environment variable: + +```bash +export OP_SERVICE_ACCOUNT_TOKEN= +``` + +3. Edit your `.npmrc` file (in your $HOME or in your project directory) to include the following: + +``` +//registry.npmjs.org/:_authToken=${NPM_TOKEN} +``` + +4. Set the environment variable `NPM_TOKEN` to the private beta token provided by 1Password: + +```bash +export NPM_TOKEN= +``` + +5. Install the 1Password JavaScript SDK: + +```bash +## NPM +npm install @1password/sdk@0.1.0-beta.2 +``` + +```bash +## PNPM +pnpm add @1password/sdk@0.1.0-beta.2 +``` + +```bash +## Yarn +yarn add @1password/sdk@0.1.0-beta.2 +``` + +6. Use the SDK in your project: + +```js +import { createClient } from "@1password/sdk"; + +// Creates an authenticated client. +const client = await createClient({ + auth: process.env.OP_SERVICE_ACCOUNT_TOKEN, + integrationName: "", + integrationVersion: "", +}); + +// Fetches a secret. +const secret = await client.secrets.resolve("op://vault/item/field"); +``` + +Make sure to use [secret reference URIs](https://developer.1password.com/docs/cli/secret-references/) with the syntax `op://vault/item/field` to securely load secrets from 1Password into your code. diff --git a/docs/classes/client.Client.md b/docs/classes/client.Client.md new file mode 100644 index 0000000..560a9ab --- /dev/null +++ b/docs/classes/client.Client.md @@ -0,0 +1,45 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [client](../modules/client.md) / Client + +# Class: Client + +[client](../modules/client.md).Client + +## Table of contents + +### Constructors + +- [constructor](client.Client.md#constructor) + +### Properties + +- [secrets](client.Client.md#secrets) + +## Constructors + +### constructor + +• **new Client**(`innerClient`): [`Client`](client.Client.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `innerClient` | [`InnerClient`](../interfaces/configuration.InnerClient.md) | + +#### Returns + +[`Client`](client.Client.md) + +#### Defined in + +client.ts:50 + +## Properties + +### secrets + +• **secrets**: [`SecretsApi`](../interfaces/secrets.SecretsApi.md) + +#### Defined in + +client.ts:48 diff --git a/docs/classes/core.SharedCore.md b/docs/classes/core.SharedCore.md new file mode 100644 index 0000000..92730d3 --- /dev/null +++ b/docs/classes/core.SharedCore.md @@ -0,0 +1,103 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / SharedCore + +# Class: SharedCore + +[core](../modules/core.md).SharedCore + +## Implements + +- [`Core`](../interfaces/core.Core.md) + +## Table of contents + +### Constructors + +- [constructor](core.SharedCore.md#constructor) + +### Methods + +- [initClient](core.SharedCore.md#initclient) +- [invoke](core.SharedCore.md#invoke) +- [releaseClient](core.SharedCore.md#releaseclient) + +## Constructors + +### constructor + +• **new SharedCore**(): [`SharedCore`](core.SharedCore.md) + +#### Returns + +[`SharedCore`](core.SharedCore.md) + +## Methods + +### initClient + +▸ **initClient**(`config`): `Promise`\<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`ClientAuthConfig`](../interfaces/core.ClientAuthConfig.md) | + +#### Returns + +`Promise`\<`string`\> + +#### Implementation of + +[Core](../interfaces/core.Core.md).[initClient](../interfaces/core.Core.md#initclient) + +#### Defined in + +core.ts:44 + +___ + +### invoke + +▸ **invoke**(`config`): `Promise`\<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`InvokeConfig`](../interfaces/core.InvokeConfig.md) | + +#### Returns + +`Promise`\<`string`\> + +#### Implementation of + +[Core](../interfaces/core.Core.md).[invoke](../interfaces/core.Core.md#invoke) + +#### Defined in + +core.ts:49 + +___ + +### releaseClient + +▸ **releaseClient**(`clientId`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `clientId` | `number` | + +#### Returns + +`void` + +#### Implementation of + +[Core](../interfaces/core.Core.md).[releaseClient](../interfaces/core.Core.md#releaseclient) + +#### Defined in + +core.ts:54 diff --git a/docs/classes/secrets.SecretsSource.md b/docs/classes/secrets.SecretsSource.md new file mode 100644 index 0000000..fde5c22 --- /dev/null +++ b/docs/classes/secrets.SecretsSource.md @@ -0,0 +1,81 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [secrets](../modules/secrets.md) / SecretsSource + +# Class: SecretsSource + +[secrets](../modules/secrets.md).SecretsSource + +Exposes functionality related to secret references. + +## Implements + +- [`SecretsApi`](../interfaces/secrets.SecretsApi.md) + +## Table of contents + +### Constructors + +- [constructor](secrets.SecretsSource.md#constructor) + +### Properties + +- [#inner](secrets.SecretsSource.md##inner) + +### Methods + +- [resolve](secrets.SecretsSource.md#resolve) + +## Constructors + +### constructor + +• **new SecretsSource**(`inner`): [`SecretsSource`](secrets.SecretsSource.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `inner` | [`InnerClient`](../interfaces/configuration.InnerClient.md) | + +#### Returns + +[`SecretsSource`](secrets.SecretsSource.md) + +#### Defined in + +secrets.ts:18 + +## Properties + +### #inner + +• `Private` **#inner**: [`InnerClient`](../interfaces/configuration.InnerClient.md) + +#### Defined in + +secrets.ts:16 + +## Methods + +### resolve + +▸ **resolve**(`secretReference`): `Promise`\<`string`\> + +Takes as input a secret reference and returns the secret to which it points. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `secretReference` | `string` | + +#### Returns + +`Promise`\<`string`\> + +#### Implementation of + +[SecretsApi](../interfaces/secrets.SecretsApi.md).[resolve](../interfaces/secrets.SecretsApi.md#resolve) + +#### Defined in + +secrets.ts:23 diff --git a/docs/interfaces/configuration.ClientConfiguration.md b/docs/interfaces/configuration.ClientConfiguration.md new file mode 100644 index 0000000..a5bed30 --- /dev/null +++ b/docs/interfaces/configuration.ClientConfiguration.md @@ -0,0 +1,43 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [configuration](../modules/configuration.md) / ClientConfiguration + +# Interface: ClientConfiguration + +[configuration](../modules/configuration.md).ClientConfiguration + +## Table of contents + +### Properties + +- [auth](configuration.ClientConfiguration.md#auth) +- [integrationName](configuration.ClientConfiguration.md#integrationname) +- [integrationVersion](configuration.ClientConfiguration.md#integrationversion) + +## Properties + +### auth + +• **auth**: `string` + +#### Defined in + +configuration.ts:11 + +___ + +### integrationName + +• **integrationName**: `string` + +#### Defined in + +configuration.ts:12 + +___ + +### integrationVersion + +• **integrationVersion**: `string` + +#### Defined in + +configuration.ts:13 diff --git a/docs/interfaces/configuration.InnerClient.md b/docs/interfaces/configuration.InnerClient.md new file mode 100644 index 0000000..ab635ff --- /dev/null +++ b/docs/interfaces/configuration.InnerClient.md @@ -0,0 +1,32 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [configuration](../modules/configuration.md) / InnerClient + +# Interface: InnerClient + +[configuration](../modules/configuration.md).InnerClient + +## Table of contents + +### Properties + +- [core](configuration.InnerClient.md#core) +- [id](configuration.InnerClient.md#id) + +## Properties + +### core + +• **core**: [`Core`](core.Core.md) + +#### Defined in + +configuration.ts:6 + +___ + +### id + +• **id**: `number` + +#### Defined in + +configuration.ts:5 diff --git a/docs/interfaces/core.ClientAuthConfig.md b/docs/interfaces/core.ClientAuthConfig.md new file mode 100644 index 0000000..6ec0d98 --- /dev/null +++ b/docs/interfaces/core.ClientAuthConfig.md @@ -0,0 +1,120 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / ClientAuthConfig + +# Interface: ClientAuthConfig + +[core](../modules/core.md).ClientAuthConfig + +## Table of contents + +### Properties + +- [architecture](core.ClientAuthConfig.md#architecture) +- [integrationName](core.ClientAuthConfig.md#integrationname) +- [integrationVersion](core.ClientAuthConfig.md#integrationversion) +- [os](core.ClientAuthConfig.md#os) +- [osVersion](core.ClientAuthConfig.md#osversion) +- [programmingLanguage](core.ClientAuthConfig.md#programminglanguage) +- [requestLibraryName](core.ClientAuthConfig.md#requestlibraryname) +- [requestLibraryVersion](core.ClientAuthConfig.md#requestlibraryversion) +- [sdkVersion](core.ClientAuthConfig.md#sdkversion) +- [serviceAccountToken](core.ClientAuthConfig.md#serviceaccounttoken) + +## Properties + +### architecture + +• **architecture**: `string` + +#### Defined in + +core.ts:24 + +___ + +### integrationName + +• **integrationName**: `string` + +#### Defined in + +core.ts:18 + +___ + +### integrationVersion + +• **integrationVersion**: `string` + +#### Defined in + +core.ts:19 + +___ + +### os + +• **os**: `string` + +#### Defined in + +core.ts:22 + +___ + +### osVersion + +• **osVersion**: `string` + +#### Defined in + +core.ts:23 + +___ + +### programmingLanguage + +• **programmingLanguage**: `string` + +#### Defined in + +core.ts:16 + +___ + +### requestLibraryName + +• **requestLibraryName**: `string` + +#### Defined in + +core.ts:20 + +___ + +### requestLibraryVersion + +• **requestLibraryVersion**: `string` + +#### Defined in + +core.ts:21 + +___ + +### sdkVersion + +• **sdkVersion**: `string` + +#### Defined in + +core.ts:17 + +___ + +### serviceAccountToken + +• **serviceAccountToken**: `string` + +#### Defined in + +core.ts:15 diff --git a/docs/interfaces/core.Core.md b/docs/interfaces/core.Core.md new file mode 100644 index 0000000..76b9c6c --- /dev/null +++ b/docs/interfaces/core.Core.md @@ -0,0 +1,77 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / Core + +# Interface: Core + +[core](../modules/core.md).Core + +## Implemented by + +- [`SharedCore`](../classes/core.SharedCore.md) + +## Table of contents + +### Methods + +- [initClient](core.Core.md#initclient) +- [invoke](core.Core.md#invoke) +- [releaseClient](core.Core.md#releaseclient) + +## Methods + +### initClient + +▸ **initClient**(`config`): `Promise`\<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`ClientAuthConfig`](core.ClientAuthConfig.md) | + +#### Returns + +`Promise`\<`string`\> + +#### Defined in + +core.ts:6 + +___ + +### invoke + +▸ **invoke**(`config`): `Promise`\<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`InvokeConfig`](core.InvokeConfig.md) | + +#### Returns + +`Promise`\<`string`\> + +#### Defined in + +core.ts:8 + +___ + +### releaseClient + +▸ **releaseClient**(`clientId`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `clientId` | `number` | + +#### Returns + +`void` + +#### Defined in + +core.ts:10 diff --git a/docs/interfaces/core.InvokeConfig.md b/docs/interfaces/core.InvokeConfig.md new file mode 100644 index 0000000..d4fc191 --- /dev/null +++ b/docs/interfaces/core.InvokeConfig.md @@ -0,0 +1,32 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / InvokeConfig + +# Interface: InvokeConfig + +[core](../modules/core.md).InvokeConfig + +## Table of contents + +### Properties + +- [clientId](core.InvokeConfig.md#clientid) +- [invocation](core.InvokeConfig.md#invocation) + +## Properties + +### clientId + +• **clientId**: `number` + +#### Defined in + +core.ts:30 + +___ + +### invocation + +• **invocation**: `Invocation` + +#### Defined in + +core.ts:31 diff --git a/docs/interfaces/secrets.SecretsApi.md b/docs/interfaces/secrets.SecretsApi.md new file mode 100644 index 0000000..13d6268 --- /dev/null +++ b/docs/interfaces/secrets.SecretsApi.md @@ -0,0 +1,39 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / [secrets](../modules/secrets.md) / SecretsApi + +# Interface: SecretsApi + +[secrets](../modules/secrets.md).SecretsApi + +Exposes functionality related to secret references. + +## Implemented by + +- [`SecretsSource`](../classes/secrets.SecretsSource.md) + +## Table of contents + +### Methods + +- [resolve](secrets.SecretsApi.md#resolve) + +## Methods + +### resolve + +▸ **resolve**(`secretReference`): `Promise`\<`string`\> + +Takes as input a secret reference and returns the secret to which it points. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `secretReference` | `string` | + +#### Returns + +`Promise`\<`string`\> + +#### Defined in + +secrets.ts:9 diff --git a/docs/modules.md b/docs/modules.md new file mode 100644 index 0000000..16d8b0f --- /dev/null +++ b/docs/modules.md @@ -0,0 +1,12 @@ +[@1password/sdk](README.md) / Modules + +# @1password/sdk + +## Table of contents + +### Modules + +- [client](modules/client.md) +- [configuration](modules/configuration.md) +- [core](modules/core.md) +- [secrets](modules/secrets.md) diff --git a/docs/modules/client.md b/docs/modules/client.md new file mode 100644 index 0000000..0778ae8 --- /dev/null +++ b/docs/modules/client.md @@ -0,0 +1,113 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / client + +# Module: client + +## Table of contents + +### Classes + +- [Client](../classes/client.Client.md) + +### Variables + +- [DEFAULT\_INTEGRATION\_NAME](client.md#default_integration_name) +- [DEFAULT\_INTEGRATION\_VERSION](client.md#default_integration_version) + +### Functions + +- [clientAuthConfig](client.md#clientauthconfig) +- [createClient](client.md#createclient) +- [createClientWithCore](client.md#createclientwithcore) + +## Variables + +### DEFAULT\_INTEGRATION\_NAME + +• `Const` **DEFAULT\_INTEGRATION\_NAME**: ``"Unknown"`` + +#### Defined in + +client.ts:6 + +___ + +### DEFAULT\_INTEGRATION\_VERSION + +• `Const` **DEFAULT\_INTEGRATION\_VERSION**: ``"Unknown"`` + +#### Defined in + +client.ts:7 + +## Functions + +### clientAuthConfig + +▸ **clientAuthConfig**(`userConfig`): [`ClientAuthConfig`](../interfaces/core.ClientAuthConfig.md) + +Creates a default client configuration. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `userConfig` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | + +#### Returns + +[`ClientAuthConfig`](../interfaces/core.ClientAuthConfig.md) + +The client configuration to instantiate the client with. + +#### Defined in + +client.ts:59 + +___ + +### createClient + +▸ **createClient**(`config`): `Promise`\<[`Client`](../classes/client.Client.md)\> + +Creates a default 1Password SDK client. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | + +#### Returns + +`Promise`\<[`Client`](../classes/client.Client.md)\> + +The authenticated 1Password SDK client. + +#### Defined in + +client.ts:22 + +___ + +### createClientWithCore + +▸ **createClientWithCore**(`config`, `core`): `Promise`\<[`Client`](../classes/client.Client.md)\> + +Creates a 1Password SDK client with a given core implementation. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | +| `core` | [`Core`](../interfaces/core.Core.md) | + +#### Returns + +`Promise`\<[`Client`](../classes/client.Client.md)\> + +The authenticated 1Password SDK client. + +#### Defined in + +client.ts:30 diff --git a/docs/modules/configuration.md b/docs/modules/configuration.md new file mode 100644 index 0000000..e7fa42c --- /dev/null +++ b/docs/modules/configuration.md @@ -0,0 +1,10 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / configuration + +# Module: configuration + +## Table of contents + +### Interfaces + +- [ClientConfiguration](../interfaces/configuration.ClientConfiguration.md) +- [InnerClient](../interfaces/configuration.InnerClient.md) diff --git a/docs/modules/core.md b/docs/modules/core.md new file mode 100644 index 0000000..6b33ad3 --- /dev/null +++ b/docs/modules/core.md @@ -0,0 +1,15 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / core + +# Module: core + +## Table of contents + +### Classes + +- [SharedCore](../classes/core.SharedCore.md) + +### Interfaces + +- [ClientAuthConfig](../interfaces/core.ClientAuthConfig.md) +- [Core](../interfaces/core.Core.md) +- [InvokeConfig](../interfaces/core.InvokeConfig.md) diff --git a/docs/modules/secrets.md b/docs/modules/secrets.md new file mode 100644 index 0000000..48bd63d --- /dev/null +++ b/docs/modules/secrets.md @@ -0,0 +1,13 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / secrets + +# Module: secrets + +## Table of contents + +### Classes + +- [SecretsSource](../classes/secrets.SecretsSource.md) + +### Interfaces + +- [SecretsApi](../interfaces/secrets.SecretsApi.md) From 14cb4686a2bc7640f9b37b67fc2b25fc4bac2db7 Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Fri, 15 Mar 2024 15:57:18 +0100 Subject: [PATCH 2/6] Hide in page TOC --- docs/classes/client.Client.md | 10 ---------- docs/classes/core.SharedCore.md | 12 ------------ docs/classes/secrets.SecretsSource.md | 14 -------------- .../configuration.ClientConfiguration.md | 8 -------- docs/interfaces/configuration.InnerClient.md | 7 ------- docs/interfaces/core.ClientAuthConfig.md | 15 --------------- docs/interfaces/core.Core.md | 8 -------- docs/interfaces/core.InvokeConfig.md | 7 ------- docs/interfaces/secrets.SecretsApi.md | 6 ------ docs/modules.md | 4 +--- docs/modules/client.md | 15 +-------------- docs/modules/configuration.md | 4 +--- docs/modules/core.md | 6 ++---- docs/modules/secrets.md | 6 ++---- 14 files changed, 7 insertions(+), 115 deletions(-) diff --git a/docs/classes/client.Client.md b/docs/classes/client.Client.md index 560a9ab..dc5f95b 100644 --- a/docs/classes/client.Client.md +++ b/docs/classes/client.Client.md @@ -4,16 +4,6 @@ [client](../modules/client.md).Client -## Table of contents - -### Constructors - -- [constructor](client.Client.md#constructor) - -### Properties - -- [secrets](client.Client.md#secrets) - ## Constructors ### constructor diff --git a/docs/classes/core.SharedCore.md b/docs/classes/core.SharedCore.md index 92730d3..c8ac5e2 100644 --- a/docs/classes/core.SharedCore.md +++ b/docs/classes/core.SharedCore.md @@ -8,18 +8,6 @@ - [`Core`](../interfaces/core.Core.md) -## Table of contents - -### Constructors - -- [constructor](core.SharedCore.md#constructor) - -### Methods - -- [initClient](core.SharedCore.md#initclient) -- [invoke](core.SharedCore.md#invoke) -- [releaseClient](core.SharedCore.md#releaseclient) - ## Constructors ### constructor diff --git a/docs/classes/secrets.SecretsSource.md b/docs/classes/secrets.SecretsSource.md index fde5c22..312cd28 100644 --- a/docs/classes/secrets.SecretsSource.md +++ b/docs/classes/secrets.SecretsSource.md @@ -10,20 +10,6 @@ Exposes functionality related to secret references. - [`SecretsApi`](../interfaces/secrets.SecretsApi.md) -## Table of contents - -### Constructors - -- [constructor](secrets.SecretsSource.md#constructor) - -### Properties - -- [#inner](secrets.SecretsSource.md##inner) - -### Methods - -- [resolve](secrets.SecretsSource.md#resolve) - ## Constructors ### constructor diff --git a/docs/interfaces/configuration.ClientConfiguration.md b/docs/interfaces/configuration.ClientConfiguration.md index a5bed30..665b939 100644 --- a/docs/interfaces/configuration.ClientConfiguration.md +++ b/docs/interfaces/configuration.ClientConfiguration.md @@ -4,14 +4,6 @@ [configuration](../modules/configuration.md).ClientConfiguration -## Table of contents - -### Properties - -- [auth](configuration.ClientConfiguration.md#auth) -- [integrationName](configuration.ClientConfiguration.md#integrationname) -- [integrationVersion](configuration.ClientConfiguration.md#integrationversion) - ## Properties ### auth diff --git a/docs/interfaces/configuration.InnerClient.md b/docs/interfaces/configuration.InnerClient.md index ab635ff..71a56d7 100644 --- a/docs/interfaces/configuration.InnerClient.md +++ b/docs/interfaces/configuration.InnerClient.md @@ -4,13 +4,6 @@ [configuration](../modules/configuration.md).InnerClient -## Table of contents - -### Properties - -- [core](configuration.InnerClient.md#core) -- [id](configuration.InnerClient.md#id) - ## Properties ### core diff --git a/docs/interfaces/core.ClientAuthConfig.md b/docs/interfaces/core.ClientAuthConfig.md index 6ec0d98..35beae1 100644 --- a/docs/interfaces/core.ClientAuthConfig.md +++ b/docs/interfaces/core.ClientAuthConfig.md @@ -4,21 +4,6 @@ [core](../modules/core.md).ClientAuthConfig -## Table of contents - -### Properties - -- [architecture](core.ClientAuthConfig.md#architecture) -- [integrationName](core.ClientAuthConfig.md#integrationname) -- [integrationVersion](core.ClientAuthConfig.md#integrationversion) -- [os](core.ClientAuthConfig.md#os) -- [osVersion](core.ClientAuthConfig.md#osversion) -- [programmingLanguage](core.ClientAuthConfig.md#programminglanguage) -- [requestLibraryName](core.ClientAuthConfig.md#requestlibraryname) -- [requestLibraryVersion](core.ClientAuthConfig.md#requestlibraryversion) -- [sdkVersion](core.ClientAuthConfig.md#sdkversion) -- [serviceAccountToken](core.ClientAuthConfig.md#serviceaccounttoken) - ## Properties ### architecture diff --git a/docs/interfaces/core.Core.md b/docs/interfaces/core.Core.md index 76b9c6c..dfac467 100644 --- a/docs/interfaces/core.Core.md +++ b/docs/interfaces/core.Core.md @@ -8,14 +8,6 @@ - [`SharedCore`](../classes/core.SharedCore.md) -## Table of contents - -### Methods - -- [initClient](core.Core.md#initclient) -- [invoke](core.Core.md#invoke) -- [releaseClient](core.Core.md#releaseclient) - ## Methods ### initClient diff --git a/docs/interfaces/core.InvokeConfig.md b/docs/interfaces/core.InvokeConfig.md index d4fc191..01aa8cf 100644 --- a/docs/interfaces/core.InvokeConfig.md +++ b/docs/interfaces/core.InvokeConfig.md @@ -4,13 +4,6 @@ [core](../modules/core.md).InvokeConfig -## Table of contents - -### Properties - -- [clientId](core.InvokeConfig.md#clientid) -- [invocation](core.InvokeConfig.md#invocation) - ## Properties ### clientId diff --git a/docs/interfaces/secrets.SecretsApi.md b/docs/interfaces/secrets.SecretsApi.md index 13d6268..17f6e9b 100644 --- a/docs/interfaces/secrets.SecretsApi.md +++ b/docs/interfaces/secrets.SecretsApi.md @@ -10,12 +10,6 @@ Exposes functionality related to secret references. - [`SecretsSource`](../classes/secrets.SecretsSource.md) -## Table of contents - -### Methods - -- [resolve](secrets.SecretsApi.md#resolve) - ## Methods ### resolve diff --git a/docs/modules.md b/docs/modules.md index 16d8b0f..3e9c523 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -2,9 +2,7 @@ # @1password/sdk -## Table of contents - -### Modules +## Modules - [client](modules/client.md) - [configuration](modules/configuration.md) diff --git a/docs/modules/client.md b/docs/modules/client.md index 0778ae8..c071fcb 100644 --- a/docs/modules/client.md +++ b/docs/modules/client.md @@ -2,23 +2,10 @@ # Module: client -## Table of contents - -### Classes +## Classes - [Client](../classes/client.Client.md) -### Variables - -- [DEFAULT\_INTEGRATION\_NAME](client.md#default_integration_name) -- [DEFAULT\_INTEGRATION\_VERSION](client.md#default_integration_version) - -### Functions - -- [clientAuthConfig](client.md#clientauthconfig) -- [createClient](client.md#createclient) -- [createClientWithCore](client.md#createclientwithcore) - ## Variables ### DEFAULT\_INTEGRATION\_NAME diff --git a/docs/modules/configuration.md b/docs/modules/configuration.md index e7fa42c..194a120 100644 --- a/docs/modules/configuration.md +++ b/docs/modules/configuration.md @@ -2,9 +2,7 @@ # Module: configuration -## Table of contents - -### Interfaces +## Interfaces - [ClientConfiguration](../interfaces/configuration.ClientConfiguration.md) - [InnerClient](../interfaces/configuration.InnerClient.md) diff --git a/docs/modules/core.md b/docs/modules/core.md index 6b33ad3..756c22b 100644 --- a/docs/modules/core.md +++ b/docs/modules/core.md @@ -2,13 +2,11 @@ # Module: core -## Table of contents - -### Classes +## Classes - [SharedCore](../classes/core.SharedCore.md) -### Interfaces +## Interfaces - [ClientAuthConfig](../interfaces/core.ClientAuthConfig.md) - [Core](../interfaces/core.Core.md) diff --git a/docs/modules/secrets.md b/docs/modules/secrets.md index 48bd63d..56c986d 100644 --- a/docs/modules/secrets.md +++ b/docs/modules/secrets.md @@ -2,12 +2,10 @@ # Module: secrets -## Table of contents - -### Classes +## Classes - [SecretsSource](../classes/secrets.SecretsSource.md) -### Interfaces +## Interfaces - [SecretsApi](../interfaces/secrets.SecretsApi.md) From b037da5692e9d5a4da20ccffd73917878d2d0afb Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Fri, 15 Mar 2024 16:31:28 +0100 Subject: [PATCH 3/6] Add docs generation with typedoc --- client/package.json | 11 +++++----- client/typedoc.json | 5 +++++ docs/classes/client.Client.md | 4 ++-- docs/classes/core.SharedCore.md | 6 +++--- docs/classes/secrets.SecretsSource.md | 10 +++------- .../configuration.ClientConfiguration.md | 6 +++--- docs/interfaces/configuration.InnerClient.md | 4 ++-- docs/interfaces/core.ClientAuthConfig.md | 20 +++++++++---------- docs/interfaces/core.Core.md | 6 +++--- docs/interfaces/core.InvokeConfig.md | 4 ++-- docs/interfaces/secrets.SecretsApi.md | 6 +----- docs/modules/client.md | 10 +++++----- package.json | 9 +++------ 13 files changed, 48 insertions(+), 53 deletions(-) create mode 100644 client/typedoc.json diff --git a/client/package.json b/client/package.json index 317a124..113f7d7 100644 --- a/client/package.json +++ b/client/package.json @@ -8,13 +8,12 @@ "prettier": "prettier --check 'src/*.ts'", "prettier-fix": "prettier --write 'src/*.ts'", "eslint": "eslint -c .eslintrc.json 'src/*.ts'", - "prepare": "npm run build" + "prepare": "npm run build", + "gen-docs": "typedoc ./src/*.ts --out ../docs" }, "author": "1Password", "license": "MIT", - "files": [ - "./dist" - ], + "files": ["./dist"], "exports": { ".": { "types": "./dist/client.d.ts", @@ -40,6 +39,8 @@ "typescript": "^5.3.3", "@types/node": "^20.11.0", "@babel/preset-env": "^7.23.8", - "babel-jest": "^29.7.0" + "babel-jest": "^29.7.0", + "typedoc": "^0.25.12", + "typedoc-plugin-markdown": "^3.17.1" } } diff --git a/client/typedoc.json b/client/typedoc.json new file mode 100644 index 0000000..02f36b9 --- /dev/null +++ b/client/typedoc.json @@ -0,0 +1,5 @@ +{ + "plugin": ["typedoc-plugin-markdown"], + "hideInPageTOC": true, + "excludeInternal": true +} diff --git a/docs/classes/client.Client.md b/docs/classes/client.Client.md index dc5f95b..f04753c 100644 --- a/docs/classes/client.Client.md +++ b/docs/classes/client.Client.md @@ -22,7 +22,7 @@ #### Defined in -client.ts:50 +[client.ts:50](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L50) ## Properties @@ -32,4 +32,4 @@ client.ts:50 #### Defined in -client.ts:48 +[client.ts:48](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L48) diff --git a/docs/classes/core.SharedCore.md b/docs/classes/core.SharedCore.md index c8ac5e2..bfff42a 100644 --- a/docs/classes/core.SharedCore.md +++ b/docs/classes/core.SharedCore.md @@ -40,7 +40,7 @@ #### Defined in -core.ts:44 +[core.ts:44](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L44) ___ @@ -64,7 +64,7 @@ ___ #### Defined in -core.ts:49 +[core.ts:49](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L49) ___ @@ -88,4 +88,4 @@ ___ #### Defined in -core.ts:54 +[core.ts:54](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L54) diff --git a/docs/classes/secrets.SecretsSource.md b/docs/classes/secrets.SecretsSource.md index 312cd28..f6f8583 100644 --- a/docs/classes/secrets.SecretsSource.md +++ b/docs/classes/secrets.SecretsSource.md @@ -4,8 +4,6 @@ [secrets](../modules/secrets.md).SecretsSource -Exposes functionality related to secret references. - ## Implements - [`SecretsApi`](../interfaces/secrets.SecretsApi.md) @@ -28,7 +26,7 @@ Exposes functionality related to secret references. #### Defined in -secrets.ts:18 +[secrets.ts:14](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L14) ## Properties @@ -38,7 +36,7 @@ secrets.ts:18 #### Defined in -secrets.ts:16 +[secrets.ts:12](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L12) ## Methods @@ -46,8 +44,6 @@ secrets.ts:16 ▸ **resolve**(`secretReference`): `Promise`\<`string`\> -Takes as input a secret reference and returns the secret to which it points. - #### Parameters | Name | Type | @@ -64,4 +60,4 @@ Takes as input a secret reference and returns the secret to which it points. #### Defined in -secrets.ts:23 +[secrets.ts:18](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L18) diff --git a/docs/interfaces/configuration.ClientConfiguration.md b/docs/interfaces/configuration.ClientConfiguration.md index 665b939..b995082 100644 --- a/docs/interfaces/configuration.ClientConfiguration.md +++ b/docs/interfaces/configuration.ClientConfiguration.md @@ -12,7 +12,7 @@ #### Defined in -configuration.ts:11 +[configuration.ts:11](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L11) ___ @@ -22,7 +22,7 @@ ___ #### Defined in -configuration.ts:12 +[configuration.ts:12](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L12) ___ @@ -32,4 +32,4 @@ ___ #### Defined in -configuration.ts:13 +[configuration.ts:13](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L13) diff --git a/docs/interfaces/configuration.InnerClient.md b/docs/interfaces/configuration.InnerClient.md index 71a56d7..7e7925a 100644 --- a/docs/interfaces/configuration.InnerClient.md +++ b/docs/interfaces/configuration.InnerClient.md @@ -12,7 +12,7 @@ #### Defined in -configuration.ts:6 +[configuration.ts:6](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L6) ___ @@ -22,4 +22,4 @@ ___ #### Defined in -configuration.ts:5 +[configuration.ts:5](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L5) diff --git a/docs/interfaces/core.ClientAuthConfig.md b/docs/interfaces/core.ClientAuthConfig.md index 35beae1..79ee6a4 100644 --- a/docs/interfaces/core.ClientAuthConfig.md +++ b/docs/interfaces/core.ClientAuthConfig.md @@ -12,7 +12,7 @@ #### Defined in -core.ts:24 +[core.ts:24](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L24) ___ @@ -22,7 +22,7 @@ ___ #### Defined in -core.ts:18 +[core.ts:18](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L18) ___ @@ -32,7 +32,7 @@ ___ #### Defined in -core.ts:19 +[core.ts:19](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L19) ___ @@ -42,7 +42,7 @@ ___ #### Defined in -core.ts:22 +[core.ts:22](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L22) ___ @@ -52,7 +52,7 @@ ___ #### Defined in -core.ts:23 +[core.ts:23](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L23) ___ @@ -62,7 +62,7 @@ ___ #### Defined in -core.ts:16 +[core.ts:16](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L16) ___ @@ -72,7 +72,7 @@ ___ #### Defined in -core.ts:20 +[core.ts:20](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L20) ___ @@ -82,7 +82,7 @@ ___ #### Defined in -core.ts:21 +[core.ts:21](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L21) ___ @@ -92,7 +92,7 @@ ___ #### Defined in -core.ts:17 +[core.ts:17](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L17) ___ @@ -102,4 +102,4 @@ ___ #### Defined in -core.ts:15 +[core.ts:15](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L15) diff --git a/docs/interfaces/core.Core.md b/docs/interfaces/core.Core.md index dfac467..87111e0 100644 --- a/docs/interfaces/core.Core.md +++ b/docs/interfaces/core.Core.md @@ -26,7 +26,7 @@ #### Defined in -core.ts:6 +[core.ts:6](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L6) ___ @@ -46,7 +46,7 @@ ___ #### Defined in -core.ts:8 +[core.ts:8](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L8) ___ @@ -66,4 +66,4 @@ ___ #### Defined in -core.ts:10 +[core.ts:10](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L10) diff --git a/docs/interfaces/core.InvokeConfig.md b/docs/interfaces/core.InvokeConfig.md index 01aa8cf..3699525 100644 --- a/docs/interfaces/core.InvokeConfig.md +++ b/docs/interfaces/core.InvokeConfig.md @@ -12,7 +12,7 @@ #### Defined in -core.ts:30 +[core.ts:30](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L30) ___ @@ -22,4 +22,4 @@ ___ #### Defined in -core.ts:31 +[core.ts:31](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L31) diff --git a/docs/interfaces/secrets.SecretsApi.md b/docs/interfaces/secrets.SecretsApi.md index 17f6e9b..e9d321a 100644 --- a/docs/interfaces/secrets.SecretsApi.md +++ b/docs/interfaces/secrets.SecretsApi.md @@ -4,8 +4,6 @@ [secrets](../modules/secrets.md).SecretsApi -Exposes functionality related to secret references. - ## Implemented by - [`SecretsSource`](../classes/secrets.SecretsSource.md) @@ -16,8 +14,6 @@ Exposes functionality related to secret references. ▸ **resolve**(`secretReference`): `Promise`\<`string`\> -Takes as input a secret reference and returns the secret to which it points. - #### Parameters | Name | Type | @@ -30,4 +26,4 @@ Takes as input a secret reference and returns the secret to which it points. #### Defined in -secrets.ts:9 +[secrets.ts:7](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L7) diff --git a/docs/modules/client.md b/docs/modules/client.md index c071fcb..994853e 100644 --- a/docs/modules/client.md +++ b/docs/modules/client.md @@ -14,7 +14,7 @@ #### Defined in -client.ts:6 +[client.ts:6](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L6) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -client.ts:7 +[client.ts:7](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L7) ## Functions @@ -48,7 +48,7 @@ The client configuration to instantiate the client with. #### Defined in -client.ts:59 +[client.ts:59](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L59) ___ @@ -72,7 +72,7 @@ The authenticated 1Password SDK client. #### Defined in -client.ts:22 +[client.ts:22](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L22) ___ @@ -97,4 +97,4 @@ The authenticated 1Password SDK client. #### Defined in -client.ts:30 +[client.ts:30](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L30) diff --git a/package.json b/package.json index 1580de9..b2996fa 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,8 @@ "prepare": "npm run build --workspace client", "prettier": "npm run prettier --workspaces --if-present", "prettier-fix": "npm run prettier-fix --workspaces --if-present", - "eslint": "npm run eslint --workspaces --if-present" + "eslint": "npm run eslint --workspaces --if-present", + "gen-docs": "npm run gen-docs --workspace client" }, - "workspaces": [ - "client", - "examples", - "wasm" - ] + "workspaces": ["client", "examples", "wasm"] } From 0435ed0c324aa872f0e12a8208460acb5c742e7e Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Fri, 15 Mar 2024 16:46:55 +0100 Subject: [PATCH 4/6] Update comments to conform to tsdoc standard and regenerate docs --- client/src/client.ts | 4 + client/src/configuration.ts | 17 ++- client/src/core.ts | 25 ++++- client/src/secrets.ts | 29 ++++- docs/classes/client.Client.md | 6 +- docs/classes/core.SharedCore.md | 91 --------------- docs/classes/secrets.SecretsSource.md | 44 ++------ .../configuration.ClientConfiguration.md | 8 +- docs/interfaces/configuration.InnerClient.md | 25 ----- docs/interfaces/core.ClientAuthConfig.md | 105 ------------------ docs/interfaces/core.Core.md | 69 ------------ docs/interfaces/core.InvokeConfig.md | 25 ----- docs/interfaces/secrets.SecretsApi.md | 14 ++- docs/modules.md | 1 - docs/modules/client.md | 18 +-- docs/modules/configuration.md | 3 +- docs/modules/core.md | 13 --- 17 files changed, 104 insertions(+), 393 deletions(-) delete mode 100644 docs/classes/core.SharedCore.md delete mode 100644 docs/interfaces/configuration.InnerClient.md delete mode 100644 docs/interfaces/core.ClientAuthConfig.md delete mode 100644 docs/interfaces/core.Core.md delete mode 100644 docs/interfaces/core.InvokeConfig.md delete mode 100644 docs/modules/core.md diff --git a/client/src/client.ts b/client/src/client.ts index e330a92..d5e56c7 100644 --- a/client/src/client.ts +++ b/client/src/client.ts @@ -1,3 +1,7 @@ +/** + Module containing the 1Password SDK Client, which can be used to authenticate and access data stored in 1Password programmatically. + @module +*/ import * as os from "os"; import { SecretsApi, SecretsSource } from "./secrets.js"; import { ClientAuthConfig, Core, SharedCore } from "./core.js"; diff --git a/client/src/configuration.ts b/client/src/configuration.ts index d34276f..b363297 100644 --- a/client/src/configuration.ts +++ b/client/src/configuration.ts @@ -1,17 +1,28 @@ +/** + Module defining configuration options for the 1Password SDK. + @module +*/ import { Core } from "./core.js"; -// Represents the client instance on which a call is made. +/** + Represents the client instance on which a call is made. + @internal +*/ export interface InnerClient { id: number; core: Core; } -// Contains information necessary to configure an SDK client. +/** + Defines all parameters that can be used to configure the 1Password SDK Client. +*/ export interface ClientConfiguration { auth: Auth; integrationName: string; integrationVersion: string; } -// Sets the authentication method. Use `string` to authenticate with a service account token. +/** + Sets the authentication method. Supply a `string` to authenticate with a service account token. +*/ type Auth = string; diff --git a/client/src/core.ts b/client/src/core.ts index 0686219..e561e50 100644 --- a/client/src/core.ts +++ b/client/src/core.ts @@ -1,6 +1,13 @@ +/** + Internal module defining the 1Password SDK Core. Users of the SDK should import and use the `client` module instead of this one. + @internal + @module +*/ import { init_client, invoke, release_client } from "@1password/sdk-core"; -// Exposes the SDK core to the host JS SDK. +/** + Exposes the SDK core to the host JS SDK. +*/ export interface Core { // Allocates a new authenticated client and returns its id. initClient(config: ClientAuthConfig): Promise; @@ -10,7 +17,9 @@ export interface Core { releaseClient(clientId: number): void; } -// Wraps configuration information needed to allocate and authenticate a client instance and sends it to the SDK core. +/** + Wraps configuration information needed to allocate and authenticate a client instance and sends it to the SDK core. +*/ export interface ClientAuthConfig { serviceAccountToken: string; programmingLanguage: string; @@ -24,14 +33,18 @@ export interface ClientAuthConfig { architecture: string; } -// Contains the information sent to the SDK core when you call (invoke) a function. +/** + Contains the information sent to the SDK core when you call (invoke) a function. +*/ export interface InvokeConfig { // Identifies the client instance for which you called the function. clientId: number; invocation: Invocation; } -// Calls certain logic from the SDK core, with the given parameters. +/** + Calls certain logic from the SDK core, with the given parameters. +*/ interface Invocation { // Functionality name name: string; @@ -39,7 +52,9 @@ interface Invocation { parameters: string; } -// An implementation of the `Core` interface that shares resources across all clients. +/** + An implementation of the `Core` interface that shares resources across all clients. +*/ export class SharedCore implements Core { public async initClient(config: ClientAuthConfig): Promise { const serializedConfig = JSON.stringify(config); diff --git a/client/src/secrets.ts b/client/src/secrets.ts index 839d7ad..dd1b6ac 100644 --- a/client/src/secrets.ts +++ b/client/src/secrets.ts @@ -1,20 +1,43 @@ +/** + Module defining the Secrets API. + + The Secrets API can be used to access secrets stored in 1Password via secret references (op://vault/item/field). + It is implemented by the 1Passwor +*/ import { InvokeConfig } from "./core.js"; import { InnerClient } from "./configuration.js"; -// Exposes functionality around secrets. +/** + Exposes functionality for retrieving secrets. +*/ export interface SecretsApi { - // Takes as input a secret reference and returns the secret to which it points. + /** + Takes as input a secret reference and returns the secret to which it points. + @param secretReference - A string containing a secret reference (string of the form "op://vault/item/field"). + @returns The value of the referenced 1Password item field. + */ resolve(secretReference: string): Promise; } -// An implementation of the `SecretsAPI` that wraps a `Core`. +/** + @inheritdoc +*/ export class SecretsSource implements SecretsApi { + /** + @internal + */ #inner: InnerClient; + /** + @internal + */ public constructor(inner: InnerClient) { this.#inner = inner; } + /** + @inheritdoc + */ public async resolve(secretReference: string): Promise { const invocationConfig: InvokeConfig = { clientId: this.#inner.id, diff --git a/docs/classes/client.Client.md b/docs/classes/client.Client.md index f04753c..fd7fc88 100644 --- a/docs/classes/client.Client.md +++ b/docs/classes/client.Client.md @@ -14,7 +14,7 @@ | Name | Type | | :------ | :------ | -| `innerClient` | [`InnerClient`](../interfaces/configuration.InnerClient.md) | +| `innerClient` | `InnerClient` | #### Returns @@ -22,7 +22,7 @@ #### Defined in -[client.ts:50](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L50) +[client.ts:54](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L54) ## Properties @@ -32,4 +32,4 @@ #### Defined in -[client.ts:48](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L48) +[client.ts:52](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L52) diff --git a/docs/classes/core.SharedCore.md b/docs/classes/core.SharedCore.md deleted file mode 100644 index bfff42a..0000000 --- a/docs/classes/core.SharedCore.md +++ /dev/null @@ -1,91 +0,0 @@ -[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / SharedCore - -# Class: SharedCore - -[core](../modules/core.md).SharedCore - -## Implements - -- [`Core`](../interfaces/core.Core.md) - -## Constructors - -### constructor - -• **new SharedCore**(): [`SharedCore`](core.SharedCore.md) - -#### Returns - -[`SharedCore`](core.SharedCore.md) - -## Methods - -### initClient - -▸ **initClient**(`config`): `Promise`\<`string`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | [`ClientAuthConfig`](../interfaces/core.ClientAuthConfig.md) | - -#### Returns - -`Promise`\<`string`\> - -#### Implementation of - -[Core](../interfaces/core.Core.md).[initClient](../interfaces/core.Core.md#initclient) - -#### Defined in - -[core.ts:44](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L44) - -___ - -### invoke - -▸ **invoke**(`config`): `Promise`\<`string`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | [`InvokeConfig`](../interfaces/core.InvokeConfig.md) | - -#### Returns - -`Promise`\<`string`\> - -#### Implementation of - -[Core](../interfaces/core.Core.md).[invoke](../interfaces/core.Core.md#invoke) - -#### Defined in - -[core.ts:49](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L49) - -___ - -### releaseClient - -▸ **releaseClient**(`clientId`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `clientId` | `number` | - -#### Returns - -`void` - -#### Implementation of - -[Core](../interfaces/core.Core.md).[releaseClient](../interfaces/core.Core.md#releaseclient) - -#### Defined in - -[core.ts:54](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L54) diff --git a/docs/classes/secrets.SecretsSource.md b/docs/classes/secrets.SecretsSource.md index f6f8583..159c109 100644 --- a/docs/classes/secrets.SecretsSource.md +++ b/docs/classes/secrets.SecretsSource.md @@ -4,60 +4,36 @@ [secrets](../modules/secrets.md).SecretsSource +Exposes functionality for retrieving secrets. + ## Implements - [`SecretsApi`](../interfaces/secrets.SecretsApi.md) -## Constructors - -### constructor - -• **new SecretsSource**(`inner`): [`SecretsSource`](secrets.SecretsSource.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `inner` | [`InnerClient`](../interfaces/configuration.InnerClient.md) | - -#### Returns - -[`SecretsSource`](secrets.SecretsSource.md) - -#### Defined in - -[secrets.ts:14](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L14) - -## Properties - -### #inner - -• `Private` **#inner**: [`InnerClient`](../interfaces/configuration.InnerClient.md) - -#### Defined in - -[secrets.ts:12](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L12) - ## Methods ### resolve ▸ **resolve**(`secretReference`): `Promise`\<`string`\> +Takes as input a secret reference and returns the secret to which it points. + #### Parameters -| Name | Type | -| :------ | :------ | -| `secretReference` | `string` | +| Name | Type | Description | +| :------ | :------ | :------ | +| `secretReference` | `string` | A string containing a secret reference (string of the form "op://vault/item/field"). | #### Returns `Promise`\<`string`\> +The value of the referenced 1Password item field. + #### Implementation of [SecretsApi](../interfaces/secrets.SecretsApi.md).[resolve](../interfaces/secrets.SecretsApi.md#resolve) #### Defined in -[secrets.ts:18](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L18) +[secrets.ts:41](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/secrets.ts#L41) diff --git a/docs/interfaces/configuration.ClientConfiguration.md b/docs/interfaces/configuration.ClientConfiguration.md index b995082..9f70207 100644 --- a/docs/interfaces/configuration.ClientConfiguration.md +++ b/docs/interfaces/configuration.ClientConfiguration.md @@ -4,6 +4,8 @@ [configuration](../modules/configuration.md).ClientConfiguration +Defines all parameters that can be used to configure the 1Password SDK Client. + ## Properties ### auth @@ -12,7 +14,7 @@ #### Defined in -[configuration.ts:11](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L11) +[configuration.ts:20](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/configuration.ts#L20) ___ @@ -22,7 +24,7 @@ ___ #### Defined in -[configuration.ts:12](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L12) +[configuration.ts:21](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/configuration.ts#L21) ___ @@ -32,4 +34,4 @@ ___ #### Defined in -[configuration.ts:13](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L13) +[configuration.ts:22](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/configuration.ts#L22) diff --git a/docs/interfaces/configuration.InnerClient.md b/docs/interfaces/configuration.InnerClient.md deleted file mode 100644 index 7e7925a..0000000 --- a/docs/interfaces/configuration.InnerClient.md +++ /dev/null @@ -1,25 +0,0 @@ -[@1password/sdk](../README.md) / [Modules](../modules.md) / [configuration](../modules/configuration.md) / InnerClient - -# Interface: InnerClient - -[configuration](../modules/configuration.md).InnerClient - -## Properties - -### core - -• **core**: [`Core`](core.Core.md) - -#### Defined in - -[configuration.ts:6](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L6) - -___ - -### id - -• **id**: `number` - -#### Defined in - -[configuration.ts:5](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/configuration.ts#L5) diff --git a/docs/interfaces/core.ClientAuthConfig.md b/docs/interfaces/core.ClientAuthConfig.md deleted file mode 100644 index 79ee6a4..0000000 --- a/docs/interfaces/core.ClientAuthConfig.md +++ /dev/null @@ -1,105 +0,0 @@ -[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / ClientAuthConfig - -# Interface: ClientAuthConfig - -[core](../modules/core.md).ClientAuthConfig - -## Properties - -### architecture - -• **architecture**: `string` - -#### Defined in - -[core.ts:24](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L24) - -___ - -### integrationName - -• **integrationName**: `string` - -#### Defined in - -[core.ts:18](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L18) - -___ - -### integrationVersion - -• **integrationVersion**: `string` - -#### Defined in - -[core.ts:19](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L19) - -___ - -### os - -• **os**: `string` - -#### Defined in - -[core.ts:22](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L22) - -___ - -### osVersion - -• **osVersion**: `string` - -#### Defined in - -[core.ts:23](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L23) - -___ - -### programmingLanguage - -• **programmingLanguage**: `string` - -#### Defined in - -[core.ts:16](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L16) - -___ - -### requestLibraryName - -• **requestLibraryName**: `string` - -#### Defined in - -[core.ts:20](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L20) - -___ - -### requestLibraryVersion - -• **requestLibraryVersion**: `string` - -#### Defined in - -[core.ts:21](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L21) - -___ - -### sdkVersion - -• **sdkVersion**: `string` - -#### Defined in - -[core.ts:17](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L17) - -___ - -### serviceAccountToken - -• **serviceAccountToken**: `string` - -#### Defined in - -[core.ts:15](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L15) diff --git a/docs/interfaces/core.Core.md b/docs/interfaces/core.Core.md deleted file mode 100644 index 87111e0..0000000 --- a/docs/interfaces/core.Core.md +++ /dev/null @@ -1,69 +0,0 @@ -[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / Core - -# Interface: Core - -[core](../modules/core.md).Core - -## Implemented by - -- [`SharedCore`](../classes/core.SharedCore.md) - -## Methods - -### initClient - -▸ **initClient**(`config`): `Promise`\<`string`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | [`ClientAuthConfig`](core.ClientAuthConfig.md) | - -#### Returns - -`Promise`\<`string`\> - -#### Defined in - -[core.ts:6](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L6) - -___ - -### invoke - -▸ **invoke**(`config`): `Promise`\<`string`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | [`InvokeConfig`](core.InvokeConfig.md) | - -#### Returns - -`Promise`\<`string`\> - -#### Defined in - -[core.ts:8](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L8) - -___ - -### releaseClient - -▸ **releaseClient**(`clientId`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `clientId` | `number` | - -#### Returns - -`void` - -#### Defined in - -[core.ts:10](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L10) diff --git a/docs/interfaces/core.InvokeConfig.md b/docs/interfaces/core.InvokeConfig.md deleted file mode 100644 index 3699525..0000000 --- a/docs/interfaces/core.InvokeConfig.md +++ /dev/null @@ -1,25 +0,0 @@ -[@1password/sdk](../README.md) / [Modules](../modules.md) / [core](../modules/core.md) / InvokeConfig - -# Interface: InvokeConfig - -[core](../modules/core.md).InvokeConfig - -## Properties - -### clientId - -• **clientId**: `number` - -#### Defined in - -[core.ts:30](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L30) - -___ - -### invocation - -• **invocation**: `Invocation` - -#### Defined in - -[core.ts:31](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/core.ts#L31) diff --git a/docs/interfaces/secrets.SecretsApi.md b/docs/interfaces/secrets.SecretsApi.md index e9d321a..3e268a3 100644 --- a/docs/interfaces/secrets.SecretsApi.md +++ b/docs/interfaces/secrets.SecretsApi.md @@ -4,6 +4,8 @@ [secrets](../modules/secrets.md).SecretsApi +Exposes functionality for retrieving secrets. + ## Implemented by - [`SecretsSource`](../classes/secrets.SecretsSource.md) @@ -14,16 +16,20 @@ ▸ **resolve**(`secretReference`): `Promise`\<`string`\> +Takes as input a secret reference and returns the secret to which it points. + #### Parameters -| Name | Type | -| :------ | :------ | -| `secretReference` | `string` | +| Name | Type | Description | +| :------ | :------ | :------ | +| `secretReference` | `string` | A string containing a secret reference (string of the form "op://vault/item/field"). | #### Returns `Promise`\<`string`\> +The value of the referenced 1Password item field. + #### Defined in -[secrets.ts:7](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/secrets.ts#L7) +[secrets.ts:19](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/secrets.ts#L19) diff --git a/docs/modules.md b/docs/modules.md index 3e9c523..125ba82 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -6,5 +6,4 @@ - [client](modules/client.md) - [configuration](modules/configuration.md) -- [core](modules/core.md) - [secrets](modules/secrets.md) diff --git a/docs/modules/client.md b/docs/modules/client.md index 994853e..f407623 100644 --- a/docs/modules/client.md +++ b/docs/modules/client.md @@ -2,6 +2,8 @@ # Module: client +Module containing the 1Password SDK Client, which can be used to authenticate and access data stored in 1Password programmatically. + ## Classes - [Client](../classes/client.Client.md) @@ -14,7 +16,7 @@ #### Defined in -[client.ts:6](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L6) +[client.ts:10](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L10) ___ @@ -24,13 +26,13 @@ ___ #### Defined in -[client.ts:7](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L7) +[client.ts:11](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L11) ## Functions ### clientAuthConfig -▸ **clientAuthConfig**(`userConfig`): [`ClientAuthConfig`](../interfaces/core.ClientAuthConfig.md) +▸ **clientAuthConfig**(`userConfig`): `ClientAuthConfig` Creates a default client configuration. @@ -42,13 +44,13 @@ Creates a default client configuration. #### Returns -[`ClientAuthConfig`](../interfaces/core.ClientAuthConfig.md) +`ClientAuthConfig` The client configuration to instantiate the client with. #### Defined in -[client.ts:59](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L59) +[client.ts:63](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L63) ___ @@ -72,7 +74,7 @@ The authenticated 1Password SDK client. #### Defined in -[client.ts:22](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L22) +[client.ts:26](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L26) ___ @@ -87,7 +89,7 @@ Creates a 1Password SDK client with a given core implementation. | Name | Type | | :------ | :------ | | `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | -| `core` | [`Core`](../interfaces/core.Core.md) | +| `core` | `Core` | #### Returns @@ -97,4 +99,4 @@ The authenticated 1Password SDK client. #### Defined in -[client.ts:30](https://github.com/1Password/1password-js-sdk/blob/14cb468/client/src/client.ts#L30) +[client.ts:34](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L34) diff --git a/docs/modules/configuration.md b/docs/modules/configuration.md index 194a120..a13975f 100644 --- a/docs/modules/configuration.md +++ b/docs/modules/configuration.md @@ -2,7 +2,8 @@ # Module: configuration +Module defining configuration options for the 1Password SDK. + ## Interfaces - [ClientConfiguration](../interfaces/configuration.ClientConfiguration.md) -- [InnerClient](../interfaces/configuration.InnerClient.md) diff --git a/docs/modules/core.md b/docs/modules/core.md deleted file mode 100644 index 756c22b..0000000 --- a/docs/modules/core.md +++ /dev/null @@ -1,13 +0,0 @@ -[@1password/sdk](../README.md) / [Modules](../modules.md) / core - -# Module: core - -## Classes - -- [SharedCore](../classes/core.SharedCore.md) - -## Interfaces - -- [ClientAuthConfig](../interfaces/core.ClientAuthConfig.md) -- [Core](../interfaces/core.Core.md) -- [InvokeConfig](../interfaces/core.InvokeConfig.md) From b588aa0abe3be8feed3a73e303b7cfd4922ecdf2 Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Tue, 19 Mar 2024 10:59:40 +0100 Subject: [PATCH 5/6] Format comments --- client/src/client.ts | 2 +- client/src/configuration.ts | 12 ++++++------ client/src/core.ts | 18 +++++++++--------- client/src/secrets.ts | 24 ++++++++++++------------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/client/src/client.ts b/client/src/client.ts index d5e56c7..2cae6ec 100644 --- a/client/src/client.ts +++ b/client/src/client.ts @@ -1,7 +1,7 @@ /** Module containing the 1Password SDK Client, which can be used to authenticate and access data stored in 1Password programmatically. @module -*/ + */ import * as os from "os"; import { SecretsApi, SecretsSource } from "./secrets.js"; import { ClientAuthConfig, Core, SharedCore } from "./core.js"; diff --git a/client/src/configuration.ts b/client/src/configuration.ts index b363297..348d7f7 100644 --- a/client/src/configuration.ts +++ b/client/src/configuration.ts @@ -1,13 +1,13 @@ /** - Module defining configuration options for the 1Password SDK. - @module -*/ + Module defining configuration options for the 1Password SDK. + @module + */ import { Core } from "./core.js"; /** Represents the client instance on which a call is made. @internal -*/ + */ export interface InnerClient { id: number; core: Core; @@ -15,7 +15,7 @@ export interface InnerClient { /** Defines all parameters that can be used to configure the 1Password SDK Client. -*/ + */ export interface ClientConfiguration { auth: Auth; integrationName: string; @@ -24,5 +24,5 @@ export interface ClientConfiguration { /** Sets the authentication method. Supply a `string` to authenticate with a service account token. -*/ + */ type Auth = string; diff --git a/client/src/core.ts b/client/src/core.ts index e561e50..ec19b10 100644 --- a/client/src/core.ts +++ b/client/src/core.ts @@ -1,13 +1,13 @@ /** - Internal module defining the 1Password SDK Core. Users of the SDK should import and use the `client` module instead of this one. - @internal - @module -*/ + Internal module defining the 1Password SDK Core. Users of the SDK should import and use the `client` module instead of this one. + @internal + @module + */ import { init_client, invoke, release_client } from "@1password/sdk-core"; /** Exposes the SDK core to the host JS SDK. -*/ + */ export interface Core { // Allocates a new authenticated client and returns its id. initClient(config: ClientAuthConfig): Promise; @@ -19,7 +19,7 @@ export interface Core { /** Wraps configuration information needed to allocate and authenticate a client instance and sends it to the SDK core. -*/ + */ export interface ClientAuthConfig { serviceAccountToken: string; programmingLanguage: string; @@ -35,7 +35,7 @@ export interface ClientAuthConfig { /** Contains the information sent to the SDK core when you call (invoke) a function. -*/ + */ export interface InvokeConfig { // Identifies the client instance for which you called the function. clientId: number; @@ -44,7 +44,7 @@ export interface InvokeConfig { /** Calls certain logic from the SDK core, with the given parameters. -*/ + */ interface Invocation { // Functionality name name: string; @@ -54,7 +54,7 @@ interface Invocation { /** An implementation of the `Core` interface that shares resources across all clients. -*/ + */ export class SharedCore implements Core { public async initClient(config: ClientAuthConfig): Promise { const serializedConfig = JSON.stringify(config); diff --git a/client/src/secrets.ts b/client/src/secrets.ts index dd1b6ac..a9fba3d 100644 --- a/client/src/secrets.ts +++ b/client/src/secrets.ts @@ -1,43 +1,43 @@ /** - Module defining the Secrets API. - - The Secrets API can be used to access secrets stored in 1Password via secret references (op://vault/item/field). - It is implemented by the 1Passwor -*/ + Module defining the Secrets API. + + The Secrets API can be used to access secrets stored in 1Password via secret references (op://vault/item/field). + It is implemented by the 1Passwor + */ import { InvokeConfig } from "./core.js"; import { InnerClient } from "./configuration.js"; /** - Exposes functionality for retrieving secrets. -*/ + Exposes functionality for retrieving secrets. + */ export interface SecretsApi { /** Takes as input a secret reference and returns the secret to which it points. @param secretReference - A string containing a secret reference (string of the form "op://vault/item/field"). @returns The value of the referenced 1Password item field. - */ + */ resolve(secretReference: string): Promise; } /** @inheritdoc -*/ + */ export class SecretsSource implements SecretsApi { /** @internal - */ + */ #inner: InnerClient; /** @internal - */ + */ public constructor(inner: InnerClient) { this.#inner = inner; } /** @inheritdoc - */ + */ public async resolve(secretReference: string): Promise { const invocationConfig: InvokeConfig = { clientId: this.#inner.id, From f156ec90c22d44a4afc7ad1460cea6c77c988c0b Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Wed, 3 Apr 2024 21:25:36 +0300 Subject: [PATCH 6/6] Add docs --- docs/README.md | 16 +++- docs/classes/client.Client.md | 4 +- docs/classes/secrets.SecretsSource.md | 2 +- .../configuration.ClientConfiguration.md | 6 +- docs/interfaces/secrets.SecretsApi.md | 2 +- docs/modules.md | 2 + docs/modules/client.md | 93 ------------------- docs/modules/client_builder.md | 28 ++++++ docs/modules/configuration.md | 24 +++++ docs/modules/sdk.md | 53 +++++++++++ 10 files changed, 125 insertions(+), 105 deletions(-) create mode 100644 docs/modules/client_builder.md create mode 100644 docs/modules/sdk.md diff --git a/docs/README.md b/docs/README.md index e063218..2106789 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,19 +10,21 @@ The 1Password JavaScript SDK offers programmatic read access to your secrets in To use the 1Password JavaScript SDK in your project: -1. [Create a 1Password Service Account](https://developer.1password.com/docs/service-accounts/get-started/#create-a-service-account). Make sure to grant the service account access to the vaults where the secrets your project needs access to are stored. +1. [Create a 1Password Service Account](https://developer.1password.com/docs/service-accounts/get-started/#create-a-service-account). You can create service accounts if you're an owner or administrator on your team. Otherwise, ask your administrator for a service account token. 2. Export your service account token to the `OP_SERVICE_ACCOUNT_TOKEN` environment variable: ```bash export OP_SERVICE_ACCOUNT_TOKEN= ``` -3. Edit your `.npmrc` file (in your $HOME or in your project directory) to include the following: +3. Edit your `.npmrc` file (in your $HOME or in your project directory) to include the following literal string: ``` //registry.npmjs.org/:_authToken=${NPM_TOKEN} ``` +> ⚠️ The `.npmrc` file should contain literally the above string, you should not add your NPM token to this file! The token will be provisioned by the `npm` CLI from the environment variable set in the next step. + 4. Set the environment variable `NPM_TOKEN` to the private beta token provided by 1Password: ```bash @@ -54,12 +56,16 @@ import { createClient } from "@1password/sdk"; // Creates an authenticated client. const client = await createClient({ auth: process.env.OP_SERVICE_ACCOUNT_TOKEN, - integrationName: "", - integrationVersion: "", + integrationName: "My 1Password Integration", + integrationVersion: "v1.0.0", }); // Fetches a secret. const secret = await client.secrets.resolve("op://vault/item/field"); ``` -Make sure to use [secret reference URIs](https://developer.1password.com/docs/cli/secret-references/) with the syntax `op://vault/item/field` to securely load secrets from 1Password into your code. +Make sure to use [secret reference URIs](https://developer.1password.com/docs/cli/secret-references/) with the syntax `op://vault/item/field` to securely load secrets from 1Password into your code. + +Note: The SDK doesn't yet support using secret references with query parameters, so you can't use secret references to retrieve file attachments or SSH keys, or to get more information about field metadata. + +Inside `createClient()`, set `integrationName` to the name of your application and `integrationVersion` to the version of your application. diff --git a/docs/classes/client.Client.md b/docs/classes/client.Client.md index fd7fc88..1ade1d8 100644 --- a/docs/classes/client.Client.md +++ b/docs/classes/client.Client.md @@ -22,7 +22,7 @@ #### Defined in -[client.ts:54](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L54) +[client.ts:12](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/client.ts#L12) ## Properties @@ -32,4 +32,4 @@ #### Defined in -[client.ts:52](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L52) +[client.ts:10](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/client.ts#L10) diff --git a/docs/classes/secrets.SecretsSource.md b/docs/classes/secrets.SecretsSource.md index 159c109..38085c0 100644 --- a/docs/classes/secrets.SecretsSource.md +++ b/docs/classes/secrets.SecretsSource.md @@ -36,4 +36,4 @@ The value of the referenced 1Password item field. #### Defined in -[secrets.ts:41](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/secrets.ts#L41) +[secrets.ts:39](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/secrets.ts#L39) diff --git a/docs/interfaces/configuration.ClientConfiguration.md b/docs/interfaces/configuration.ClientConfiguration.md index 9f70207..ee07545 100644 --- a/docs/interfaces/configuration.ClientConfiguration.md +++ b/docs/interfaces/configuration.ClientConfiguration.md @@ -14,7 +14,7 @@ Defines all parameters that can be used to configure the 1Password SDK Client. #### Defined in -[configuration.ts:20](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/configuration.ts#L20) +[configuration.ts:16](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/configuration.ts#L16) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[configuration.ts:21](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/configuration.ts#L21) +[configuration.ts:17](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/configuration.ts#L17) ___ @@ -34,4 +34,4 @@ ___ #### Defined in -[configuration.ts:22](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/configuration.ts#L22) +[configuration.ts:18](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/configuration.ts#L18) diff --git a/docs/interfaces/secrets.SecretsApi.md b/docs/interfaces/secrets.SecretsApi.md index 3e268a3..69f7bf6 100644 --- a/docs/interfaces/secrets.SecretsApi.md +++ b/docs/interfaces/secrets.SecretsApi.md @@ -32,4 +32,4 @@ The value of the referenced 1Password item field. #### Defined in -[secrets.ts:19](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/secrets.ts#L19) +[secrets.ts:17](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/secrets.ts#L17) diff --git a/docs/modules.md b/docs/modules.md index 125ba82..2ce2ee1 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -5,5 +5,7 @@ ## Modules - [client](modules/client.md) +- [client\_builder](modules/client_builder.md) - [configuration](modules/configuration.md) +- [sdk](modules/sdk.md) - [secrets](modules/secrets.md) diff --git a/docs/modules/client.md b/docs/modules/client.md index f407623..8b3dba1 100644 --- a/docs/modules/client.md +++ b/docs/modules/client.md @@ -7,96 +7,3 @@ Module containing the 1Password SDK Client, which can be used to authenticate an ## Classes - [Client](../classes/client.Client.md) - -## Variables - -### DEFAULT\_INTEGRATION\_NAME - -• `Const` **DEFAULT\_INTEGRATION\_NAME**: ``"Unknown"`` - -#### Defined in - -[client.ts:10](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L10) - -___ - -### DEFAULT\_INTEGRATION\_VERSION - -• `Const` **DEFAULT\_INTEGRATION\_VERSION**: ``"Unknown"`` - -#### Defined in - -[client.ts:11](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L11) - -## Functions - -### clientAuthConfig - -▸ **clientAuthConfig**(`userConfig`): `ClientAuthConfig` - -Creates a default client configuration. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `userConfig` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | - -#### Returns - -`ClientAuthConfig` - -The client configuration to instantiate the client with. - -#### Defined in - -[client.ts:63](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L63) - -___ - -### createClient - -▸ **createClient**(`config`): `Promise`\<[`Client`](../classes/client.Client.md)\> - -Creates a default 1Password SDK client. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | - -#### Returns - -`Promise`\<[`Client`](../classes/client.Client.md)\> - -The authenticated 1Password SDK client. - -#### Defined in - -[client.ts:26](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L26) - -___ - -### createClientWithCore - -▸ **createClientWithCore**(`config`, `core`): `Promise`\<[`Client`](../classes/client.Client.md)\> - -Creates a 1Password SDK client with a given core implementation. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | -| `core` | `Core` | - -#### Returns - -`Promise`\<[`Client`](../classes/client.Client.md)\> - -The authenticated 1Password SDK client. - -#### Defined in - -[client.ts:34](https://github.com/1Password/1password-js-sdk/blob/b037da5/client/src/client.ts#L34) diff --git a/docs/modules/client_builder.md b/docs/modules/client_builder.md new file mode 100644 index 0000000..e55733a --- /dev/null +++ b/docs/modules/client_builder.md @@ -0,0 +1,28 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / client\_builder + +# Module: client\_builder + +## Functions + +### createClientWithCore + +▸ **createClientWithCore**(`config`, `core`): `Promise`\<[`Client`](../classes/client.Client.md)\> + +Creates a 1Password SDK client with a given core implementation. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | +| `core` | `Core` | + +#### Returns + +`Promise`\<[`Client`](../classes/client.Client.md)\> + +The authenticated 1Password SDK client. + +#### Defined in + +[client_builder.ts:15](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/client_builder.ts#L15) diff --git a/docs/modules/configuration.md b/docs/modules/configuration.md index a13975f..264a258 100644 --- a/docs/modules/configuration.md +++ b/docs/modules/configuration.md @@ -7,3 +7,27 @@ Module defining configuration options for the 1Password SDK. ## Interfaces - [ClientConfiguration](../interfaces/configuration.ClientConfiguration.md) + +## Functions + +### clientAuthConfig + +▸ **clientAuthConfig**(`userConfig`): `ClientAuthConfig` + +Creates a default client configuration. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `userConfig` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | + +#### Returns + +`ClientAuthConfig` + +The client configuration to instantiate the client with. + +#### Defined in + +[configuration.ts:30](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/configuration.ts#L30) diff --git a/docs/modules/sdk.md b/docs/modules/sdk.md new file mode 100644 index 0000000..1bc818a --- /dev/null +++ b/docs/modules/sdk.md @@ -0,0 +1,53 @@ +[@1password/sdk](../README.md) / [Modules](../modules.md) / sdk + +# Module: sdk + +## References + +### Client + +Re-exports [Client](../classes/client.Client.md) + +## Variables + +### DEFAULT\_INTEGRATION\_NAME + +• `Const` **DEFAULT\_INTEGRATION\_NAME**: ``"Unknown"`` + +#### Defined in + +[sdk.ts:6](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/sdk.ts#L6) + +___ + +### DEFAULT\_INTEGRATION\_VERSION + +• `Const` **DEFAULT\_INTEGRATION\_VERSION**: ``"Unknown"`` + +#### Defined in + +[sdk.ts:7](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/sdk.ts#L7) + +## Functions + +### createClient + +▸ **createClient**(`config`): `Promise`\<[`Client`](../classes/client.Client.md)\> + +Creates a default 1Password SDK client. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`ClientConfiguration`](../interfaces/configuration.ClientConfiguration.md) | + +#### Returns + +`Promise`\<[`Client`](../classes/client.Client.md)\> + +The authenticated 1Password SDK client. + +#### Defined in + +[sdk.ts:15](https://github.com/1Password/1password-js-sdk/blob/8f949b4/client/src/sdk.ts#L15)