mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-08-03 11:07:00 -04:00
(nuxt) load apple private key directly where needed
This commit is contained in:
parent
6825cf7821
commit
c555a8468b
@ -40,9 +40,6 @@ const version = fs.existsSync(versionFile) ? fs.readFileSync(versionFile).toStri
|
|||||||
const publicKeyFile = `${__dirname}/keys/public.pem`;
|
const publicKeyFile = `${__dirname}/keys/public.pem`;
|
||||||
const publicKey = fs.existsSync(publicKeyFile) ? fs.readFileSync(publicKeyFile).toString('utf-8') : undefined;
|
const publicKey = fs.existsSync(publicKeyFile) ? fs.readFileSync(publicKeyFile).toString('utf-8') : undefined;
|
||||||
|
|
||||||
const applePrivateKeyFile = `${__dirname}/keys/AuthKey_${process.env.APPLE_KEY_ID}.p8`;
|
|
||||||
process.env.APPLE_PRIVATE_KEY = fs.existsSync(applePrivateKeyFile) ? fs.readFileSync(applePrivateKeyFile).toString('utf-8') : '';
|
|
||||||
|
|
||||||
const allLocalesUrls = buildList(function*() {
|
const allLocalesUrls = buildList(function*() {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
if (process.env.BASE_URL) {
|
if (process.env.BASE_URL) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
import fs from 'fs';
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import type { GrantConfig, GrantResponse } from 'grant';
|
import type { GrantConfig, GrantResponse } from 'grant';
|
||||||
|
import { rootDir } from './paths.ts';
|
||||||
|
|
||||||
const getAppleClientSecret = (): string => {
|
const getAppleClientSecret = (): string => {
|
||||||
const headers = {
|
const headers = {
|
||||||
@ -12,7 +14,9 @@ const getAppleClientSecret = (): string => {
|
|||||||
aud: 'https://appleid.apple.com',
|
aud: 'https://appleid.apple.com',
|
||||||
sub: process.env.APPLE_CLIENT_ID,
|
sub: process.env.APPLE_CLIENT_ID,
|
||||||
};
|
};
|
||||||
return jwt.sign(claims, process.env.APPLE_PRIVATE_KEY!, {
|
const applePrivateKeyFile = `${rootDir}/keys/AuthKey_${process.env.APPLE_KEY_ID}.p8`;
|
||||||
|
const privateKey = fs.existsSync(applePrivateKeyFile) ? fs.readFileSync(applePrivateKeyFile).toString('utf-8') : '';
|
||||||
|
return jwt.sign(claims, privateKey, {
|
||||||
algorithm: 'ES256',
|
algorithm: 'ES256',
|
||||||
header: headers,
|
header: headers,
|
||||||
expiresIn: '180d',
|
expiresIn: '180d',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user