-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: pull up TurboBaseFactory to common
Implement private in enviornment specific TurboFactory, update examples in README
- Loading branch information
dtfiedler
committed
Sep 6, 2023
1 parent
3acba94
commit 96208ea
Showing
6 changed files
with
137 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { TurboPublicConfiguration } from '../types/turbo.js'; | ||
import { TurboUnauthenticatedPaymentService } from './payment.js'; | ||
import { TurboUnauthenticatedClient } from './turbo.js'; | ||
import { TurboUnauthenticatedUploadService } from './upload.js'; | ||
|
||
export class TurboBaseFactory { | ||
static public({ | ||
paymentServiceConfig = {}, | ||
uploadServiceConfig = {}, | ||
}: TurboPublicConfiguration = {}) { | ||
const paymentService = new TurboUnauthenticatedPaymentService({ | ||
...paymentServiceConfig, | ||
}); | ||
const uploadService = new TurboUnauthenticatedUploadService({ | ||
...uploadServiceConfig, | ||
}); | ||
return new TurboUnauthenticatedClient({ | ||
uploadService, | ||
paymentService, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { TurboBaseFactory } from '../common/factory.js'; | ||
import { | ||
TurboAuthenticatedClient, | ||
TurboAuthenticatedPaymentService, | ||
TurboAuthenticatedUploadService, | ||
} from '../common/index.js'; | ||
import { TurboPrivateConfiguration } from '../types/index.js'; | ||
import { TurboNodeArweaveSigner } from './signer.js'; | ||
|
||
export class TurboFactory extends TurboBaseFactory { | ||
static private({ | ||
privateKey, | ||
paymentServiceConfig = {}, | ||
uploadServiceConfig = {}, | ||
}: TurboPrivateConfiguration) { | ||
const signer = new TurboNodeArweaveSigner({ privateKey }); | ||
const paymentService = new TurboAuthenticatedPaymentService({ | ||
...paymentServiceConfig, | ||
signer, | ||
}); | ||
const uploadService = new TurboAuthenticatedUploadService({ | ||
...uploadServiceConfig, | ||
signer, | ||
}); | ||
return new TurboAuthenticatedClient({ | ||
uploadService, | ||
paymentService, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { TurboBaseFactory } from '../common/factory.js'; | ||
import { | ||
TurboAuthenticatedClient, | ||
TurboAuthenticatedPaymentService, | ||
TurboAuthenticatedUploadService, | ||
} from '../common/index.js'; | ||
import { TurboPrivateConfiguration } from '../types/index.js'; | ||
import { TurboWebArweaveSigner } from './signer.js'; | ||
|
||
export class TurboFactory extends TurboBaseFactory { | ||
static private({ | ||
privateKey, | ||
paymentServiceConfig = {}, | ||
uploadServiceConfig = {}, | ||
}: TurboPrivateConfiguration) { | ||
const signer = new TurboWebArweaveSigner({ privateKey }); | ||
const paymentService = new TurboAuthenticatedPaymentService({ | ||
...paymentServiceConfig, | ||
signer, | ||
}); | ||
const uploadService = new TurboAuthenticatedUploadService({ | ||
...uploadServiceConfig, | ||
signer, | ||
}); | ||
return new TurboAuthenticatedClient({ | ||
uploadService, | ||
paymentService, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters