History

Fix beta distribution release flow

Rhys Sullivan committed 7 months ago

Commit ab58a3e1 parent 17ab9314 files · +209 −54Browse files

Showing the changes to plugins (1 of 4 files). Show all

Unified · Split

plugins/keychain-secret-store/sdk/index.ts+28−11
@@ -1,7 +1,4 @@
1import { randomUUID } from "node:crypto";1import { randomUUID } from "node:crypto";
2import {
3 Entry,
4} from "@napi-rs/keyring";
5 2
6import * as Effect from "effect/Effect";3import * as Effect from "effect/Effect";
7 4
@@ -51,12 +48,13 @@ const keychainDisplayName = () => · 43 unmodified lines
51 ? "Windows Credential Manager"48 ? "Windows Credential Manager"
52 : "Desktop Keyring";49 : "Desktop Keyring";
53 50
54const createKeyringEntry = (input: {51let keyringEntryConstructorPromise: Promise<
55 providerHandle: string;52 (typeof import("@napi-rs/keyring"))["Entry"]
56 keychainServiceName: string;53> | null = null;
57}) =>54
58 Effect.try({55const loadKeyringEntryConstructor = () =>
59 try: () => {56 Effect.tryPromise({
57 try: async () => {
60 if (!isSupportedPlatform()) {58 if (!isSupportedPlatform()) {
61 throw runtimeEffectError(59 throw runtimeEffectError(
62 "plugin-keychain-secret-store",60 "plugin-keychain-secret-store",
@@ -64,11 +62,30 @@ const createKeyringEntry = (input: { · 1 unmodified line
64 );62 );
65 }63 }
66 64
67 return new Entry(input.keychainServiceName, input.providerHandle);65 keyringEntryConstructorPromise ??= import("@napi-rs/keyring").then(
66 ({ Entry }) => Entry,
67 );
68
69 return await keyringEntryConstructorPromise;
68 },70 },
69 catch: toError,71 catch: (cause) =>
72 runtimeEffectError(
73 "plugin-keychain-secret-store",
74 `system-keyring: failed loading native keyring support: ${toError(cause).message}`,
75 ),
70 });76 });
71 77
78const createKeyringEntry = (input: {
79 providerHandle: string;
80 keychainServiceName: string;
81}) =>
82 Effect.flatMap(loadKeyringEntryConstructor(), (Entry) =>
83 Effect.try({
84 try: () => new Entry(input.keychainServiceName, input.providerHandle),
85 catch: toError,
86 })
87 );
88
72const readKeychainSecretValue = (input: {89const readKeychainSecretValue = (input: {
73 providerHandle: string;90 providerHandle: string;
74 keychainServiceName: string;91 keychainServiceName: string;